ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject ignite git commit: IGNITE-3098: imroved the fix
Date Tue, 17 May 2016 04:34:44 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-3098 5c8fce86e -> 5f4a4398a


IGNITE-3098: imroved the fix


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

Branch: refs/heads/ignite-3098
Commit: 5f4a4398a4e958e33797af8f1c6e06e95c483299
Parents: 5c8fce8
Author: Denis Magda <dmagda@gridgain.com>
Authored: Tue May 17 07:34:39 2016 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Tue May 17 07:34:39 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/binary/BinaryUtils.java     | 17 ++--
 .../binary/BinaryMarshallerSelfTest.java        | 96 +++++++++++---------
 2 files changed, 58 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5f4a4398/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 0d3d7b6..157d47b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -2135,13 +2135,10 @@ public class BinaryUtils {
         for (cnt = 0; cnt < strLen; cnt++) {
             c = val.charAt(cnt);
 
-            // ASCII
-            if (c <= 0x007F)
+            if (c >= 0x0001 && c <= 0x007F)
                 utfLen++;
-                // Special symbols (surrogates)
             else if (c > 0x07FF)
                 utfLen += 3;
-                // The rest of the symbols.
             else
                 utfLen += 2;
         }
@@ -2153,16 +2150,16 @@ public class BinaryUtils {
         for (cnt = 0; cnt < strLen; cnt++) {
             c = val.charAt(cnt);
 
-            if (c <= 0x007F)
+            if (c >= 0x0001 && c <= 0x007F)
                 arr[position++] = (byte)c;
             else if (c > 0x07FF) {
-                arr[position++] = (byte)(0xE0 | c >> 12 & 0x0F);
-                arr[position++] = (byte)(0x80 | c >> 6 & 0x3F);
-                arr[position++] = (byte)(0x80 | c & 0x3F);
+                arr[position++] = (byte)(0xE0 | (c >> 12) & 0x0F);
+                arr[position++] = (byte)(0x80 | (c >> 6) & 0x3F);
+                arr[position++] = (byte)(0x80 | (c & 0x3F));
             }
             else {
-                arr[position++] = (byte)(0xC0 | c >> 6 & 0x1F);
-                arr[position++] = (byte)(0x80 | c & 0x3F);
+                arr[position++] = (byte)(0xC0 | ((c >> 6) & 0x1F));
+                arr[position++] = (byte)(0x80 | (c  & 0x3F));
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5f4a4398/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index e0b46d4..a45f13d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -203,14 +203,17 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         assertEquals(str, new String(bytes, UTF_8));
 
         // Special symbols check.
-        str = new String(new char[]{0xD800, '的', 0xD800, 0xD800, 0xDC00, 0xDFFF});
+        str = new String(new char[] {0xD800, '的', 0xD800, 0xD800, 0xDC00, 0xDFFF});
         assertEquals(str, marshalUnmarshal(str));
 
-        str = new String(new char[]{55296});
+        str = new String(new char[] {55296});
         assertEquals(str, marshalUnmarshal(str));
 
         bytes = str.getBytes(UTF_8);
         assertNotEquals(str, BinaryUtils.utf8BytesToStr(bytes, 0, bytes.length));
+
+        str = new String(new char[] {0xD801, 0xDC37});
+        assertEquals(str, marshalUnmarshal(str));
     }
 
     /**
@@ -321,7 +324,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testDecimalArray() throws Exception {
-        BigDecimal[] arr = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN}
;
+        BigDecimal[] arr = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN};
 
         assertArrayEquals(arr, marshalUnmarshal(arr));
     }
@@ -942,9 +945,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      */
     public void testClassWithoutPublicConstructor() throws Exception {
         BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
-                new BinaryTypeConfiguration(NoPublicConstructor.class.getName()),
-                new BinaryTypeConfiguration(NoPublicDefaultConstructor.class.getName()),
-                new BinaryTypeConfiguration(ProtectedConstructor.class.getName()))
+            new BinaryTypeConfiguration(NoPublicConstructor.class.getName()),
+            new BinaryTypeConfiguration(NoPublicDefaultConstructor.class.getName()),
+            new BinaryTypeConfiguration(ProtectedConstructor.class.getName()))
         );
 
         NoPublicConstructor npc = new NoPublicConstructor();
@@ -1064,8 +1067,10 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
             @Override public int fieldId(int typeId, String fieldName) {
                 assert typeId == 44444;
 
-                if ("val1".equals(fieldName)) return 55555;
-                else if ("val2".equals(fieldName)) return 66666;
+                if ("val1".equals(fieldName))
+                    return 55555;
+                else if ("val2".equals(fieldName))
+                    return 66666;
 
                 assert false : "Unknown field: " + fieldName;
 
@@ -1433,14 +1438,14 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true),
             Arrays.asList(
-            new BinaryTypeConfiguration(Key.class.getName()),
-            new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
-            new BinaryTypeConfiguration("NonExistentClass4"),
-            customType1,
-            customType2,
-            customType3,
-            customType4
-        ));
+                new BinaryTypeConfiguration(Key.class.getName()),
+                new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+                new BinaryTypeConfiguration("NonExistentClass4"),
+                customType1,
+                customType2,
+                customType3,
+                customType4
+            ));
 
         BinaryContext ctx = binaryContext(marsh);
 
@@ -1621,6 +1626,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         // BinaryIdMapper.typeId() contract.
         assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
     }
+
     /**
      * @throws Exception If failed.
      */
@@ -1723,7 +1729,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         assertEquals(992, ctx.typeId("org.gridgain.NonExistentClass3"));
         assertEquals(993, ctx.typeId("NonExistentClass4"));
 
-
         // Custom types.
         assertEquals(300, ctx.typeId(Value.class.getName()));
         assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
@@ -2020,7 +2025,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1,
2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[] {1,
2, 3}));
 
         assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
 
@@ -2057,7 +2062,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("sArr", new short[]{1,
2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("sArr", new short[] {1,
2, 3}));
 
         assertArrayEquals(new short[] {1, 2, 3}, copy.<short[]>field("sArr"));
 
@@ -2078,7 +2083,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("iArr", new int[]{1, 2,
3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("iArr", new int[] {1,
2, 3}));
 
         assertArrayEquals(new int[] {1, 2, 3}, copy.<int[]>field("iArr"));
 
@@ -2099,7 +2104,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("lArr", new long[]{1,
2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("lArr", new long[] {1,
2, 3}));
 
         assertArrayEquals(new long[] {1, 2, 3}, copy.<long[]>field("lArr"));
 
@@ -2120,7 +2125,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("fArr", new float[]{1,
2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("fArr", new float[] {1,
2, 3}));
 
         assertArrayEquals(new float[] {1, 2, 3}, copy.<float[]>field("fArr"), 0);
 
@@ -2141,7 +2146,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("dArr", new double[]{1,
2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("dArr", new double[] {1,
2, 3}));
 
         assertArrayEquals(new double[] {1, 2, 3}, copy.<double[]>field("dArr"), 0);
 
@@ -2162,13 +2167,13 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("cArr", new char[]{1,
2, 3}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("cArr", new char[] {1,
2, 3}));
 
-        assertArrayEquals(new char[]{1, 2, 3}, copy.<char[]>field("cArr"));
+        assertArrayEquals(new char[] {1, 2, 3}, copy.<char[]>field("cArr"));
 
         SimpleObject obj0 = copy.deserialize();
 
-        assertArrayEquals(new char[]{1, 2, 3}, obj0.cArr);
+        assertArrayEquals(new char[] {1, 2, 3}, obj0.cArr);
     }
 
     /**
@@ -2183,7 +2188,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         BinaryObject po = marshal(obj, marsh);
 
-        BinaryObject copy = copy(po, F.<String, Object>asMap("strArr", new String[]{"str1",
"str2"}));
+        BinaryObject copy = copy(po, F.<String, Object>asMap("strArr", new String[]
{"str1", "str2"}));
 
         assertArrayEquals(new String[] {"str1", "str2"}, copy.<String[]>field("strArr"));
 
@@ -2241,13 +2246,13 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
         map.put("str", "str555");
         map.put("inner", newObj);
-        map.put("bArr", new byte[]{6, 7, 9});
+        map.put("bArr", new byte[] {6, 7, 9});
 
         BinaryObject copy = copy(po, map);
 
         assertEquals("str555", copy.<String>field("str"));
         assertEquals(newObj, copy.<BinaryObject>field("inner").deserialize());
-        assertArrayEquals(new byte[]{6, 7, 9}, copy.<byte[]>field("bArr"));
+        assertArrayEquals(new byte[] {6, 7, 9}, copy.<byte[]>field("bArr"));
 
         SimpleObject obj0 = copy.deserialize();
 
@@ -2470,7 +2475,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         DecimalReflective obj1 = new DecimalReflective();
 
         obj1.val = BigDecimal.ZERO;
-        obj1.valArr = new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN };
+        obj1.valArr = new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN};
 
         BinaryObjectImpl portObj = marshal(obj1, marsh);
 
@@ -2484,9 +2489,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         DecimalMarshalAware obj2 = new DecimalMarshalAware();
 
         obj2.val = BigDecimal.ZERO;
-        obj2.valArr = new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN.negate() };
+        obj2.valArr = new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN.negate()};
         obj2.rawVal = BigDecimal.TEN;
-        obj2.rawValArr = new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ONE };
+        obj2.rawValArr = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ONE};
 
         portObj = marshal(obj2, marsh);
 
@@ -2818,7 +2823,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
     /**
      * Some non-serializable class.
      */
-    @SuppressWarnings( {"PublicField","TransientFieldInNonSerializableClass","FieldMayBeStatic"})
+    @SuppressWarnings({"PublicField", "TransientFieldInNonSerializableClass", "FieldMayBeStatic"})
     private static class NonSerializableA {
         /** */
         private final long longVal = 0x33445566778899AAL;
@@ -2827,7 +2832,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         protected Short shortVal = (short)0xAABB;
 
         /** */
-        public String[] strArr = {"AA","BB"};
+        public String[] strArr = {"AA", "BB"};
 
         /** */
         public boolean flag1 = true;
@@ -2851,7 +2856,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
          * @param strArr Array.
          * @param shortVal Short value.
          */
-        @SuppressWarnings( {"UnusedDeclaration"})
+        @SuppressWarnings({"UnusedDeclaration"})
         private NonSerializableA(@Nullable String[] strArr, @Nullable Short shortVal) {
             // No-op.
         }
@@ -2864,7 +2869,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
 
             assertEquals(shortVal.shortValue(), (short)0xAABB);
 
-            assertTrue(Arrays.equals(strArr, new String[] {"AA","BB"}));
+            assertTrue(Arrays.equals(strArr, new String[] {"AA", "BB"}));
 
             assertEquals(0, intVal);
 
@@ -2879,7 +2884,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
     /**
      * Some non-serializable class.
      */
-    @SuppressWarnings( {"PublicField","TransientFieldInNonSerializableClass","PackageVisibleInnerClass"})
+    @SuppressWarnings({"PublicField", "TransientFieldInNonSerializableClass", "PackageVisibleInnerClass"})
     static class NonSerializableB extends NonSerializableA {
         /** */
         public Short shortValue = 0x1122;
@@ -2923,7 +2928,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
     /**
      * Some non-serializable class.
      */
-    @SuppressWarnings( {"TransientFieldInNonSerializableClass","PublicField"})
+    @SuppressWarnings({"TransientFieldInNonSerializableClass", "PublicField"})
     private static class NonSerializable extends NonSerializableB {
         /** */
         private int idVal = -17;
@@ -2948,7 +2953,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
          *
          * @param aVal Unused.
          */
-        @SuppressWarnings( {"UnusedDeclaration"})
+        @SuppressWarnings({"UnusedDeclaration"})
         private NonSerializable(NonSerializableA aVal) {
         }
 
@@ -3138,7 +3143,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
     /**
      *
      */
-    protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper
mapper, Collection<BinaryTypeConfiguration> cfgs)
+    protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper
mapper,
+        Collection<BinaryTypeConfiguration> cfgs)
         throws IgniteCheckedException {
         return binaryMarshaller(nameMapper, mapper, null, cfgs);
     }
@@ -3280,7 +3286,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         outer.inner = inner;
         outer.bdArr = new BigDecimal[] {new BigDecimal(5000), BigDecimal.TEN};
 
-
         outer.col.add("str4");
         outer.col.add("str5");
         outer.col.add("str6");
@@ -4359,7 +4364,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
             // No-op.
         }
 
-        /**n
+        /**
+         * n
+         *
          * @param key Key.
          */
         private Key(int key) {
@@ -4470,7 +4477,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
      */
     private static class ProtectedConstructor {
         /**
-         *  Protected constructor.
+         * Protected constructor.
          */
         protected ProtectedConstructor() {
             // No-op.
@@ -4526,8 +4533,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest
{
         /** */
         private String s;
 
-        /** Initializer. */
-        {
+        /** Initializer. */ {
             StringBuilder builder = new StringBuilder();
 
             for (int i = 0; i < 10000; i++) {


Mime
View raw message