pavlukhin commented on a change in pull request #7320: IGNITE-12468 Java thin 
client: deserialization of arrays, collections and maps fixed
URL: https://github.com/apache/ignite/pull/7320#discussion_r375805290
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientUtils.java
 ##########
 @@ -522,12 +528,73 @@ void writeObject(BinaryOutputStream out, Object obj) {
 
     /** Read Ignite binary object from input stream. */
     <T> T readObject(BinaryInputStream in, boolean keepBinary) {
-        Object val = marsh.unmarshal(in);
+        if (keepBinary)
+            return (T)marsh.unmarshal(in);
+        else {
+            BinaryReaderHandles hnds = new BinaryReaderHandles();
+
+            return (T)unwrapBinary(marsh.deserialize(in, hnds), hnds);
+        }
+    }
+
+    /**
+     * Unwrap binary object.
+     */
+    private Object unwrapBinary(Object obj, BinaryReaderHandles hnds) {
+        if (obj instanceof BinaryObjectImpl) {
+            BinaryObjectImpl obj0 = (BinaryObjectImpl)obj;
+
+            return 
marsh.deserialize(BinaryHeapInputStream.create(obj0.array(), obj0.start()), 
hnds);
+        }
+        else if (obj instanceof BinaryObject )
+            return ((BinaryObject)obj).deserialize();
+        else if (BinaryUtils.knownCollection(obj))
+            return unwrapCollection((Collection<Objects>)obj, hnds);
+        else if (BinaryUtils.knownMap(obj))
+            return unwrapMap((Map<Object, Object>)obj, hnds);
+        else if (obj instanceof Object[])
+            return unwrapArray((Object[])obj, hnds);
+        else
+            return obj;
+    }
+
+    /**
+     * Unwrap collection with binary objects.
+     */
+    private Collection<Object> unwrapCollection(Collection<Objects> col, 
BinaryReaderHandles hnds) {
 
 Review comment:
   `Collection<Objects> col` seems to be a typo (Object**s**). It seems we can 
use raw `Collection` type here.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to