You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/11/03 13:08:31 UTC

ignite git commit: IGNITE-1848: Fixed a bug with Class field reading through portable API.

Repository: ignite
Updated Branches:
  refs/heads/ignite-1282 845c4f272 -> 433806d5e


IGNITE-1848: Fixed a bug with Class field reading through portable API.


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

Branch: refs/heads/ignite-1282
Commit: 433806d5ebc633742b143280a119609e21a4000f
Parents: 845c4f2
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Nov 3 15:09:16 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Nov 3 15:09:16 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/PortableReaderExImpl.java |  2 +-
 .../GridPortableMarshallerSelfTest.java         | 73 +++++++++++++-------
 2 files changed, 49 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/433806d5/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
index 061a9fd..9a088f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
@@ -1614,7 +1614,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
                 return doReadEnumArray(doReadClass());
 
             case CLASS:
-                return in.readInt();
+                return doReadClass();
 
             case OPTM_MARSH:
                 int len = in.readInt();

http://git-wip-us.apache.org/repos/asf/ignite/blob/433806d5/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
index ec7110f..917ba03 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
@@ -17,29 +17,7 @@
 
 package org.apache.ignite.internal.portable;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.InetSocketAddress;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListSet;
+import junit.framework.Assert;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.util.GridUnsafe;
@@ -53,7 +31,6 @@ import org.apache.ignite.marshaller.portable.PortableMarshaller;
 import org.apache.ignite.portable.PortableBuilder;
 import org.apache.ignite.portable.PortableException;
 import org.apache.ignite.portable.PortableIdMapper;
-import org.apache.ignite.portable.PortableInvalidClassException;
 import org.apache.ignite.portable.PortableMarshalAware;
 import org.apache.ignite.portable.PortableMetadata;
 import org.apache.ignite.portable.PortableObject;
@@ -68,6 +45,29 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.jsr166.ConcurrentHashMap8;
 import sun.misc.Unsafe;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetSocketAddress;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListSet;
+
 import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
 import static org.junit.Assert.assertArrayEquals;
 
@@ -2135,6 +2135,21 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testClass() throws Exception {
+        PortableMarshaller marsh = new PortableMarshaller();
+
+        initPortableContext(marsh);
+
+        Class cls = GridPortableMarshallerSelfTest.class;
+
+        Class unmarshalledCls = marshalUnmarshal(cls, marsh);
+
+        Assert.assertEquals(cls, unmarshalledCls);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testClassFieldsMarshalling() throws Exception {
         PortableMarshaller marsh = new PortableMarshaller();
 
@@ -2149,6 +2164,12 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
 
         assertEquals(obj.cls1, obj2.cls1);
         assertNull(obj2.cls2);
+
+        PortableObject portObj = marshal(obj, marsh);
+
+        Class cls1 = portObj.field("cls1");
+
+        assertEquals(obj.cls1, cls1);
     }
 
     /**
@@ -2266,11 +2287,13 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
     }
 
     /**
-     *
+     * Object with class fields.
      */
     private static class ObjectWithClassFields {
+        /** */
         private Class<?> cls1;
 
+        /** */
         private Class<?> cls2;
     }