ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-2100: Fixed "mustDeserialize" logic.
Date Thu, 17 Dec 2015 09:42:34 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2100 d5e5c7032 -> b932135cd


IGNITE-2100: Fixed "mustDeserialize" logic.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b932135c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b932135c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b932135c

Branch: refs/heads/ignite-2100
Commit: b932135cdd58a2b566e2b11d7f7ca2b92d3db96e
Parents: d5e5c70
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Dec 17 12:43:31 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Dec 17 12:43:31 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/binary/BinaryContext.java   | 37 +++++++++++++++++---
 1 file changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b932135c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 30ad6bc..abe283e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -247,9 +247,12 @@ public class BinaryContext implements Externalizable {
      * @return {@code True} if must be deserialized.
      */
     public boolean mustDeserialize(Class cls) {
-        BinaryClassDescriptor desc = descriptorForClass(cls, false);
+        BinaryClassDescriptor desc = descByCls.get(cls);
 
-        return desc.useOptimizedMarshaller();
+        if (desc == null)
+            return marshCtx.isSystemType(cls.getName()) || serializerForClass(cls) == null;
+        else
+            return desc.useOptimizedMarshaller();
     }
 
     /**
@@ -576,8 +579,7 @@ public class BinaryContext implements Externalizable {
             throw new BinaryObjectException("Failed to register class.", e);
         }
 
-        BinarySerializer serializer = BinaryUtils.isBinarylizable(cls) || !BinaryUtils.isCustomJavaSerialization(cls)
?
-            new BinaryReflectiveSerializer() : defaultSerializer();
+        BinarySerializer serializer = serializerForClass(cls);
 
         String affFieldName = affinityFieldName(cls);
 
@@ -613,6 +615,21 @@ public class BinaryContext implements Externalizable {
     }
 
     /**
+     * Get serializer for class taking in count default one.
+     *
+     * @param cls Class.
+     * @return Serializer for class or {@code null} if none exists.
+     */
+    private @Nullable BinarySerializer serializerForClass(Class cls) {
+        BinarySerializer serializer = defaultSerializer();
+
+        if (serializer == null && canUseReflectiveSerializer(cls))
+            serializer = new BinaryReflectiveSerializer();
+
+        return serializer;
+    }
+
+    /**
      * @return Default serializer.
      */
     private BinarySerializer defaultSerializer() {
@@ -822,7 +839,7 @@ public class BinaryContext implements Externalizable {
                 // At this point we must decide whether to rely on Java serialization mechanics
or not.
                 // If no serializer is provided, we examine the class and if it doesn't contain
non-trivial
                 // serialization logic we are safe to fallback to reflective binary serialization.
-                if (BinaryUtils.isBinarylizable(cls) || !BinaryUtils.isCustomJavaSerialization(cls))
+                if (canUseReflectiveSerializer(cls))
                     serializer = new BinaryReflectiveSerializer();
             }
 
@@ -852,6 +869,16 @@ public class BinaryContext implements Externalizable {
     }
 
     /**
+     * Check whether reflective serializer can be used for class.
+     *
+     * @param cls Class.
+     * @return {@code True} if reflective serializer can be used.
+     */
+    private static boolean canUseReflectiveSerializer(Class cls) {
+        return BinaryUtils.isBinarylizable(cls) || !BinaryUtils.isCustomJavaSerialization(cls);
+    }
+
+    /**
      * Create binary field.
      *
      * @param typeId Type ID.


Mime
View raw message