ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [44/66] [abbrv] ignite git commit: IGNITE-1282: Fixed JVM crash in portable builder caused by incorrect position calculation.
Date Thu, 05 Nov 2015 03:28:36 GMT
IGNITE-1282: Fixed JVM crash in portable builder caused by incorrect position calculation.


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

Branch: refs/heads/ignite-1753-1282
Commit: 178e91390e58786791bbd12c6a2f460ae240fa73
Parents: 7e399e8
Author: thatcoach <ppozerov@list.ru>
Authored: Wed Nov 4 10:03:27 2015 +0300
Committer: thatcoach <ppozerov@list.ru>
Committed: Wed Nov 4 10:03:27 2015 +0300

----------------------------------------------------------------------
 .../portable/builder/PortableBuilderImpl.java   | 32 +++++++++++---------
 .../IgnitePortableObjectsTestSuite.java         |  5 ++-
 2 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/178e9139/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
index 608425d..a28a908 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
@@ -245,27 +245,28 @@ public class PortableBuilderImpl implements PortableBuilder {
                     int fieldId = reader.readIntPositioned(footerPos);
                     int fieldLen = fieldPositionAndLength(footerPos, footerEnd, rawPos, fieldOffsetSize).get2();
 
+                    int postLen = reader.position() + fieldLen; // Position where reader
will be placed afterwards.
+
                     footerPos += 4 + fieldOffsetSize;
 
                     if (assignedFldsById.containsKey(fieldId)) {
                         Object assignedVal = assignedFldsById.remove(fieldId);
 
-                        reader.skip(fieldLen);
-
                         if (assignedVal != REMOVED_FIELD_MARKER) {
                             writer.writeFieldId(fieldId);
 
                             serializer.writeValue(writer, assignedVal);
                         }
-                    } else {
+                    }
+                    else {
                         int type = fieldLen != 0 ? reader.readByte(0) : 0;
 
                         if (fieldLen != 0 && !PortableUtils.isPlainArrayType(type)
&& PortableUtils.isPlainType(type)) {
                             writer.writeFieldId(fieldId);
-                            writer.write(reader.array(), reader.position(), fieldLen);
 
-                            reader.skip(fieldLen);
-                        } else {
+                            writer.write(reader.array(), reader.position(), fieldLen);
+                        }
+                        else {
                             writer.writeFieldId(fieldId);
 
                             Object val;
@@ -273,20 +274,18 @@ public class PortableBuilderImpl implements PortableBuilder {
                             if (fieldLen == 0)
                                 val = null;
                             else if (readCache == null) {
-                                int savedPos = reader.position();
-
                                 val = reader.parseValue();
 
-                                assert reader.position() == savedPos + fieldLen;
-                            } else {
-                                val = readCache.get(fieldId);
-
-                                reader.skip(fieldLen);
+                                assert reader.position() == postLen;
                             }
+                            else
+                                val = readCache.get(fieldId);
 
                             serializer.writeValue(writer, val);
                         }
                     }
+
+                    reader.position(postLen);
                 }
             }
 
@@ -411,15 +410,20 @@ public class PortableBuilderImpl implements PortableBuilder {
         // Get field length.
         int fieldLen;
 
-        if (footerPos + 4 + fieldOffsetSize == footerEnd)
+        if (footerPos + 4 + fieldOffsetSize == footerEnd) {
             // This is the last field, compare to raw offset.
             fieldLen = rawPos - fieldPos;
+
+            fieldLen = fieldLen * 1;
+        }
         else {
             // Field is somewhere in the middle, get difference with the next offset.
             int nextFieldOffset = PortableUtils.fieldOffsetRelative(reader, footerPos + 4
+ fieldOffsetSize + 4,
                 fieldOffsetSize);
 
             fieldLen = nextFieldOffset - fieldOffset;
+
+            fieldLen = fieldLen * 1;
         }
 
         return F.t(fieldPos, fieldLen);

http://git-wip-us.apache.org/repos/asf/ignite/blob/178e9139/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
index 3cfd530..6d8e12d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
@@ -28,7 +28,6 @@ import org.apache.ignite.internal.portable.GridPortableMarshallerSelfTest;
 import org.apache.ignite.internal.portable.GridPortableMetaDataDisabledSelfTest;
 import org.apache.ignite.internal.portable.GridPortableMetaDataSelfTest;
 import org.apache.ignite.internal.portable.GridPortableWildcardsSelfTest;
-import org.apache.ignite.internal.portable.PortableCompactOffsetsAbstractSelfTest;
 import org.apache.ignite.internal.portable.PortableCompactOffsetsHeapSelfTest;
 import org.apache.ignite.internal.portable.PortableCompactOffsetsOffheapSelfTest;
 import org.apache.ignite.internal.portable.PortableFieldsHeapSelfTest;
@@ -65,6 +64,8 @@ public class IgnitePortableObjectsTestSuite extends TestSuite {
         suite.addTestSuite(GridPortableMarshallerCtxDisabledSelfTest.class);
         suite.addTestSuite(GridPortableBuilderSelfTest.class);
         suite.addTestSuite(GridPortableBuilderStringAsCharsSelfTest.class);
+        suite.addTestSuite(GridPortableBuilderAdditionalSelfTest.class);
+        suite.addTestSuite(GridPortableBuilderStringAsCharsAdditionalSelfTest.class);
         suite.addTestSuite(PortableFieldsHeapSelfTest.class);
         suite.addTestSuite(PortableFieldsOffheapSelfTest.class);
         suite.addTestSuite(PortableCompactOffsetsHeapSelfTest.class);
@@ -73,8 +74,6 @@ public class IgnitePortableObjectsTestSuite extends TestSuite {
         suite.addTestSuite(GridPortableMetaDataDisabledSelfTest.class);
         suite.addTestSuite(GridPortableAffinityKeySelfTest.class);
         suite.addTestSuite(GridPortableWildcardsSelfTest.class);
-        suite.addTestSuite(GridPortableBuilderAdditionalSelfTest.class);
-        suite.addTestSuite(GridPortableBuilderStringAsCharsAdditionalSelfTest.class);
 
         suite.addTestSuite(GridCachePortableObjectsLocalSelfTest.class);
         suite.addTestSuite(GridCachePortableObjectsAtomicLocalSelfTest.class);


Mime
View raw message