ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/9] incubator-ignite git commit: # ignite-281 Fixed npe CacheJdbcPojoStore.
Date Wed, 25 Feb 2015 10:45:22 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-136 c98217776 -> f33c07486


# ignite-281 Fixed npe CacheJdbcPojoStore.


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

Branch: refs/heads/ignite-136
Commit: 7ada6a5f5a339b1282bd554c068b380254f78065
Parents: dd6c24f
Author: anovikov <anovikov@gridgain.com>
Authored: Wed Feb 18 15:03:07 2015 +0700
Committer: anovikov <anovikov@gridgain.com>
Committed: Wed Feb 18 15:28:42 2015 +0700

----------------------------------------------------------------------
 .../cache/store/jdbc/CacheJdbcPojoStore.java    | 28 +++++++++++++++-----
 1 file changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7ada6a5f/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
index 8687d90..0c6292d 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
@@ -69,7 +69,7 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object,
Object> {
                 throw new CacheException("Failed to find class: " + clsName, e);
             }
             catch (NoSuchMethodException e) {
-                throw new CacheException("Failed to find empty constructor for class: " +
clsName, e);
+                throw new CacheException("Failed to find default constructor for class: "
+ clsName, e);
             }
 
             setters = U.newHashMap(fields.size());
@@ -87,8 +87,8 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object,
Object> {
                         getters.put(field.getJavaName(), cls.getMethod("is" + prop));
                     }
                     catch (NoSuchMethodException e) {
-                        throw new CacheException("Failed to find getter for property " +
field.getJavaName() +
-                            " of class: " + cls.getName(), e);
+                        throw new CacheException("Failed to find getter in pojo class [class
name: " + clsName +
+                            ", property: " + field.getJavaName() + "]", e);
                     }
                 }
 
@@ -96,8 +96,8 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object,
Object> {
                     setters.put(field.getJavaName(), cls.getMethod("set" + prop, field.getJavaType()));
                 }
                 catch (NoSuchMethodException e) {
-                    throw new CacheException("Failed to find setter for property " + field.getJavaName()
+
-                        " of class: " + clsName, e);
+                    throw new CacheException("Failed to find setter in pojo class [class
name: " + clsName +
+                        ", property: " + field.getJavaName() + "]", e);
                 }
             }
         }
@@ -157,12 +157,19 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object,
Object> {
         Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException
{
         PojoMethodsCache mc = mtdsCache.get(cacheName).get(typeName);
 
+        if (mc == null)
+            throw new CacheLoaderException("Failed to find cache type metadata for type:
" + typeName);
+
         Object obj = mc.newInstance();
 
         try {
             for (CacheTypeFieldMetadata field : fields) {
                 Method setter = mc.setters.get(field.getJavaName());
 
+                if (setter == null)
+                    throw new CacheLoaderException("Failed to find setter in pojo class [class
name:" + typeName +
+                        ", property: " + field.getJavaName() + "]");
+
                 Integer colIdx = loadColIdxs.get(field.getDatabaseName());
 
                 setter.invoke(obj, getColumnValue(rs, colIdx, field.getJavaType()));
@@ -181,7 +188,16 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object,
Object> {
         try {
             PojoMethodsCache mc = mtdsCache.get(cacheName).get(typeName);
 
-            return mc.getters.get(fieldName).invoke(obj);
+            if (mc == null)
+                throw new CacheException("Failed to find cache type metadata for type: "
+ typeName);
+
+            Method getter = mc.getters.get(fieldName);
+
+            if (getter == null)
+                throw new CacheLoaderException("Failed to find getter in pojo class [class
name:" + typeName +
+                    ", property: " + fieldName + "]");
+
+            return getter.invoke(obj);
         }
         catch (Exception e) {
             throw new CacheException("Failed to read object of class: " + typeName, e);


Mime
View raw message