You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/01/11 19:18:36 UTC

[GitHub] [ignite] nizhikov commented on a change in pull request #8635: IGNITE-13958 .NET: Implicit binary type registration in Compute and Cache API

nizhikov commented on a change in pull request #8635:
URL: https://github.com/apache/ignite/pull/8635#discussion_r555281005



##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
##########
@@ -35,28 +35,43 @@ internal class FutureConverter<T> : IFutureConverter<T>
         /** Converting function. */
         private readonly Func<BinaryReader, T> _func;
 
+        /** True if should register type both for dotnet and java platforms. */
+        private readonly bool _registerSameJavaType;
+
         /// <summary>
         /// Constructor.
         /// </summary>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="keepBinary">Keep binary flag.</param>
         /// <param name="func">Converting function.</param>
+        /// <param name="registerSameJavaType">True if should register type both for dotnet and java platforms.</param>	
         public FutureConverter(Marshaller marsh, bool keepBinary,
-            Func<BinaryReader, T> func = null)
+            Func<BinaryReader, T> func = null, bool registerSameJavaType = false)
         {
             _marsh = marsh;
             _keepBinary = keepBinary;
             _func = func ?? (reader => reader == null ? default(T) : reader.ReadObject<T>());
+            _registerSameJavaType = registerSameJavaType;
         }
 
         /// <summary>
         /// Read and convert a value.
         /// </summary>
         public T Convert(IBinaryStream stream)
         {
-            var reader = stream == null ? null : _marsh.StartUnmarshal(stream, _keepBinary);
+            var locRegisterSameJavaType = Marshaller.RegisterSameJavaType.Value;
+            Marshaller.RegisterSameJavaType.Value = _registerSameJavaType;
+
+            try
+            {
+                var reader = stream == null ? null : _marsh.StartUnmarshal(stream, _keepBinary);

Review comment:
       These changes required for reading binary object of unregistered type and dynamically resolve those type.
   Please, take a look at `ComputeApiTypeAutoRegisterTest#TestEchoTasksAutoRegisterType`




----------------------------------------------------------------
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:
users@infra.apache.org