ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [18/43] ignite git commit: ignite-1282 - Fixing tests.
Date Thu, 26 Nov 2015 13:14:00 GMT
ignite-1282 - Fixing tests.


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

Branch: refs/heads/ignite-1.5-cache-get-opts
Commit: 9c1b7656a39496f03950158bc7fc2305eacdc6d1
Parents: 22326cc
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Wed Nov 25 12:25:47 2015 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Wed Nov 25 12:25:47 2015 +0300

----------------------------------------------------------------------
 .../builder/BinaryObjectBuilderImpl.java        |  9 ++----
 .../processors/query/GridQueryProcessor.java    | 26 +++++++++++------
 .../portable/BinaryObjectBuilderSelfTest.java   | 30 ++++++++++++++++++++
 .../cache/IgniteCacheAbstractQuerySelfTest.java |  2 +-
 4 files changed, 51 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9c1b7656/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
index b2fb7d8..d330c72 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
@@ -31,7 +31,6 @@ import org.apache.ignite.internal.portable.PortableContext;
 import org.apache.ignite.internal.portable.PortableSchema;
 import org.apache.ignite.internal.portable.PortableSchemaRegistry;
 import org.apache.ignite.internal.portable.PortableUtils;
-import org.apache.ignite.internal.util.GridArgumentCheck;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
@@ -492,15 +491,15 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder
{
     }
 
     /** {@inheritDoc} */
-    @Override public BinaryObjectBuilder setField(String name, Object val) {
-        GridArgumentCheck.notNull(val, name);
+    @Override public BinaryObjectBuilder setField(String name, Object val0) {
+        Object val = val0 == null ? new PortableValueWithType(PortableUtils.typeByClass(Object.class),
null) : val0;
 
         if (assignedVals == null)
             assignedVals = new LinkedHashMap<>();
 
         Object oldVal = assignedVals.put(name, val);
 
-        if (oldVal instanceof PortableValueWithType) {
+        if (oldVal instanceof PortableValueWithType && val0 != null) {
             ((PortableValueWithType)oldVal).value(val);
 
             assignedVals.put(name, oldVal);
@@ -514,8 +513,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
         if (assignedVals == null)
             assignedVals = new LinkedHashMap<>();
 
-        //int fldId = ctx.fieldId(typeId, fldName);
-
         assignedVals.put(name, new PortableValueWithType(PortableUtils.typeByClass(type),
val));
 
         return this;

http://git-wip-us.apache.org/repos/asf/ignite/blob/9c1b7656/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index c560e4e..90bb9a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1546,28 +1546,36 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
             bld.setCharAt(3, Character.toUpperCase(bld.charAt(3)));
 
-            String[] mtdNames = new String[] {bld.toString(), prop};
-
             ClassProperty tmp = null;
 
-            for (String mtdName : mtdNames) {
+            try {
+                tmp = new ClassProperty(cls.getMethod(bld.toString()), key, alias);
+            }
+            catch (NoSuchMethodException ignore) {
+                // No-op.
+            }
+
+            if (tmp == null) {
                 try {
-                    tmp = new ClassProperty(cls.getMethod(mtdName), key, alias);
+                    tmp = new ClassProperty(cls.getDeclaredField(prop), key, alias);
                 }
-                catch (NoSuchMethodException ignore) {
-                    // No-op, will try another method or field.
+                catch (NoSuchFieldException ignored) {
+                    // No-op.
                 }
             }
 
             if (tmp == null) {
                 try {
-                    tmp = new ClassProperty(cls.getDeclaredField(prop), key, alias);
+                    tmp = new ClassProperty(cls.getMethod(prop), key, alias);
                 }
-                catch (NoSuchFieldException ignored) {
-                    return null;
+                catch (NoSuchMethodException ignored) {
+                    // No-op.
                 }
             }
 
+            if (tmp == null)
+                return null;
+
             tmp.parent(res);
 
             cls = tmp.type();

http://git-wip-us.apache.org/repos/asf/ignite/blob/9c1b7656/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
index a57ed0d..eb16939 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
@@ -125,6 +125,36 @@ public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If failed.
      */
+    public void testNullField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(42);
+
+        builder.setField("objField", (Object)null);
+
+        builder.setField("otherField", "value");
+
+        BinaryObject obj = builder.build();
+
+        assertNull(obj.field("objField"));
+        assertEquals("value", obj.field("otherField"));
+        assertEquals(42, obj.hashCode());
+
+        builder = builder(obj);
+
+        builder.setField("objField", "value");
+        builder.setField("otherField", (Object)null);
+
+        obj = builder.build();
+
+        assertNull(obj.field("otherField"));
+        assertEquals("value", obj.field("objField"));
+        assertEquals(42, obj.hashCode());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testByteField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9c1b7656/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index f3fbf15..e324302 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -1372,7 +1372,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         /**
          * @return Salary.
          */
-        public double salary() {
+        public int salary() {
             return salary;
         }
 


Mime
View raw message