ptupitsyn commented on a change in pull request #8635:
URL: https://github.com/apache/ignite/pull/8635#discussion_r560000364
##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
##########
@@ -582,7 +597,7 @@ private BinaryFullTypeDescriptor RegisterType(Type type,
BinaryFullTypeDescripto
var typeName = GetTypeName(type);
var typeId = GetTypeId(typeName, _cfg.IdMapper);
- var registered = _ignite != null &&
_ignite.BinaryProcessor.RegisterType(typeId, typeName,
RegisterSameJavaType.Value);
+ var registered = _ignite != null &&
_ignite.BinaryProcessor.RegisterType(typeId, typeName, _registerSameJavaType);
Review comment:
`_registerSameJavaType` -> `RegisterSameJavaType`
##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformJniTarget.cs
##########
@@ -177,6 +177,9 @@ public T OutStream<T>(int type, Func<IBinaryStream, T>
readAction)
}
catch (JavaException jex)
{
+ if (errorAction != null)
+ return errorAction.Invoke(jex);
Review comment:
I think this should be `return
errorAction.Invoke(ConvertException(jex));`. Otherwise, when `errorAction`
rethrows the exception, it is not converted properly.
##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
##########
@@ -445,7 +445,7 @@ public dynamic GetDynamicServiceProxy(string name, bool
sticky)
}
finally
{
- Marshaller.RegisterSameJavaType.Value = false;
+ Marshaller.RegisterSameJavaTypeTl.Value = false;
Review comment:
Let's preserve the previous thread-local value instead of assuming it to
be false. Nested .NET -> Java -> .NET -> Java -> ... calls are possible.
##########
File path:
modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
##########
@@ -165,41 +167,39 @@ public BinaryType RegisterEnum(string typeName,
IEnumerable<KeyValuePair<string,
/// Gets the type name by id.
/// </summary>
/// <param name="id">The identifier.</param>
+ /// <param name="registerSameJavaType">True if should register type
both for dotnet and java platforms.</param>
/// <returns>Type or null.</returns>
- public string GetTypeName(int id)
+ public string GetTypeName(int id, bool registerSameJavaType)
{
- try
+ return GetTypeName(id, DotNetPlatformId, ex =>
{
- return GetTypeName(id, DotNetPlatformId);
- }
- catch (BinaryObjectException)
- {
- if (!Marshaller.RegisterSameJavaType.Value)
- throw;
- }
+ if (!registerSameJavaType)
+ throw ex;
Review comment:
Stack trace gets lost when we rethrow an exception like this. It should
be wrapped in another exception, e.g. `new BinaryObjectException("Unknown type
ID: " + id, ex)`
##########
File path:
modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
##########
@@ -165,41 +167,39 @@ public BinaryType RegisterEnum(string typeName,
IEnumerable<KeyValuePair<string,
/// Gets the type name by id.
/// </summary>
/// <param name="id">The identifier.</param>
+ /// <param name="registerSameJavaType">True if should register type
both for dotnet and java platforms.</param>
/// <returns>Type or null.</returns>
- public string GetTypeName(int id)
+ public string GetTypeName(int id, bool registerSameJavaType)
{
- try
+ return GetTypeName(id, DotNetPlatformId, ex =>
{
- return GetTypeName(id, DotNetPlatformId);
- }
- catch (BinaryObjectException)
- {
- if (!Marshaller.RegisterSameJavaType.Value)
- throw;
- }
+ if (!registerSameJavaType)
+ throw ex;
- // Try to get java type name and register corresponding DotNet
type.
- var javaTypeName = GetTypeName(id, JavaPlatformId);
- var netTypeName = Marshaller.GetTypeName(javaTypeName);
+ // Try to get java type name and register corresponding DotNet
type.
Review comment:
This retry logic is duplicated in `BinaryProcessor` and
`BinaryProcessorClient`. Let's move this to the `Marshaller` class.
##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
##########
@@ -434,7 +434,7 @@ public dynamic GetDynamicServiceProxy(string name, bool
sticky)
private object InvokeProxyMethod(IPlatformTargetInternal proxy, string
methodName,
MethodBase method, object[] args, PlatformType platformType)
{
- Marshaller.RegisterSameJavaType.Value = true;
+ Marshaller.RegisterSameJavaTypeTl.Value = true;
Review comment:
`if (platformType == PlatformType.Java)`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]