ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [15/40] ignite git commit: IGNITE-3235 Failed to initialize primitive boolean cache property of superclass
Date Mon, 17 Oct 2016 17:59:12 GMT
IGNITE-3235 Failed to initialize primitive boolean cache property of superclass


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: b9c776a8423471706ecb1dc6176b38f23e799077
Parents: 952be8b
Author: Anton Vinogradov <av@apache.org>
Authored: Mon Oct 10 11:52:57 2016 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Mon Oct 10 11:52:57 2016 +0300

----------------------------------------------------------------------
 .../internal/jdbc2/JdbcResultSetSelfTest.java   | 91 +++++++++++++++++++-
 .../configuration/CacheConfiguration.java       | 13 ++-
 .../processors/query/GridQueryProcessor.java    | 71 +++++++++------
 3 files changed, 142 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b9c776a8/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
index 3607f53..cc67a65 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
@@ -60,7 +60,8 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
     /** SQL query. */
     private static final String SQL =
         "select id, boolVal, byteVal, shortVal, intVal, longVal, floatVal, " +
-            "doubleVal, bigVal, strVal, arrVal, dateVal, timeVal, tsVal, urlVal, f1, f2,
f3, _val " +
+            "doubleVal, bigVal, strVal, arrVal, dateVal, timeVal, tsVal, urlVal, f1, f2,
f3, _val, " +
+            "boolVal2, boolVal3, boolVal4 " +
             "from TestObject where id = 1";
 
     /** Statement. */
@@ -142,6 +143,9 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
         TestObject o = new TestObject(id);
 
         o.boolVal = true;
+        o.boolVal2 = true;
+        o.boolVal3 = true;
+        o.boolVal4 = true;
         o.byteVal = 1;
         o.shortVal = 1;
         o.intVal = 1;
@@ -182,6 +186,66 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testBoolean2() throws Exception {
+        ResultSet rs = stmt.executeQuery(SQL);
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0) {
+                assert rs.getBoolean("boolVal2");
+                assert rs.getBoolean(20);
+            }
+
+            cnt++;
+        }
+
+        assert cnt == 1;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBoolean3() throws Exception {
+        ResultSet rs = stmt.executeQuery(SQL);
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0) {
+                assert rs.getBoolean("boolVal3");
+                assert rs.getBoolean(21);
+            }
+
+            cnt++;
+        }
+
+        assert cnt == 1;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBoolean4() throws Exception {
+        ResultSet rs = stmt.executeQuery(SQL);
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0) {
+                assert rs.getBoolean("boolVal4");
+                assert rs.getBoolean(22);
+            }
+
+            cnt++;
+        }
+
+        assert cnt == 1;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testByte() throws Exception {
         ResultSet rs = stmt.executeQuery(SQL);
 
@@ -562,7 +626,30 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
      * Test object.
      */
     @SuppressWarnings("UnusedDeclaration")
-    private static class TestObject implements Serializable {
+    private static class BaseTestObject implements Serializable {
+        /** */
+        @QuerySqlField(index = false)
+        protected Boolean boolVal2;
+
+        /** */
+        @QuerySqlField(index = false)
+        protected boolean boolVal3;
+
+        /** */
+        protected boolean boolVal4;
+
+        /** */
+        @QuerySqlField(index = false)
+        public boolean isBoolVal4() {
+            return boolVal4;
+        }
+    }
+
+    /**
+     * Test object.
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject extends BaseTestObject {
         /** */
         @QuerySqlField
         private final int id;

http://git-wip-us.apache.org/repos/asf/ignite/blob/b9c776a8/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index e28aad5..f65bf52 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -2668,10 +2668,17 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
         ClassProperty(Member member) {
             this.member = member;
 
-            name = member instanceof Method && member.getName().startsWith("get")
&& member.getName().length() > 3 ?
-                member.getName().substring(3) : member.getName();
+            name = member.getName();
 
-            ((AccessibleObject) member).setAccessible(true);
+            if (member instanceof Method) {
+                if (member.getName().startsWith("get") && member.getName().length()
> 3)
+                    name = member.getName().substring(3);
+
+                if (member.getName().startsWith("is") && member.getName().length()
> 2)
+                    name = member.getName().substring(2);
+            }
+
+            ((AccessibleObject)member).setAccessible(true);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b9c776a8/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 8469a7c..1605188 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
@@ -17,6 +17,30 @@
 
 package org.apache.ignite.internal.processors.query;
 
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import javax.cache.Cache;
+import javax.cache.CacheException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
@@ -68,31 +92,6 @@ import org.apache.ignite.spi.indexing.IndexingQueryFilter;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
-import javax.cache.Cache;
-import javax.cache.CacheException;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-
 import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED;
 import static org.apache.ignite.internal.IgniteComponentType.INDEXING;
 import static org.apache.ignite.internal.processors.query.GridQueryIndexType.FULLTEXT;
@@ -1686,15 +1685,31 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 // No-op.
             }
 
-            if (tmp == null) {
+            if (tmp == null) { // Boolean getter can be defined as is###().
+                bld = new StringBuilder("is");
+
+                bld.append(prop);
+
+                bld.setCharAt(2, Character.toUpperCase(bld.charAt(2)));
+
                 try {
-                    tmp = new ClassProperty(cls.getDeclaredField(prop), key, alias, coCtx);
+                    tmp = new ClassProperty(cls.getMethod(bld.toString()), key, alias, coCtx);
                 }
-                catch (NoSuchFieldException ignored) {
+                catch (NoSuchMethodException ignore) {
                     // No-op.
                 }
             }
 
+            Class cls0 = cls;
+
+            while (tmp == null && cls0 != null)
+                try {
+                    tmp = new ClassProperty(cls0.getDeclaredField(prop), key, alias, coCtx);
+                }
+                catch (NoSuchFieldException ignored) {
+                    cls0 = cls0.getSuperclass();
+                }
+
             if (tmp == null) {
                 try {
                     tmp = new ClassProperty(cls.getMethod(prop), key, alias, coCtx);


Mime
View raw message