cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [cayenne] 02/02: CAY-2617 NPE in processing hierarchical prefetch node - process null case
Date Thu, 12 Sep 2019 13:24:22 GMT
This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit a206d11be983c1ec1557f39c0de292d1b0a02eb0
Author: Nikita Timofeev <stariy95@gmail.com>
AuthorDate: Thu Sep 12 15:32:13 2019 +0300

    CAY-2617 NPE in processing hierarchical prefetch node
     - process null case
---
 .../src/main/java/org/apache/cayenne/access/ObjectResolver.java    | 7 +++----
 .../java/org/apache/cayenne/access/PrefetchProcessorJointNode.java | 6 ++----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectResolver.java b/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectResolver.java
index 50a0023..c04d082 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectResolver.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/ObjectResolver.java
@@ -290,12 +290,11 @@ class ObjectResolver {
 
 			// null either means a bug in Cayenne (e.g. CAY-2101) or the inheritance qualifiers are
messed up
 			if(entityName == null) {
-
 				if(LOGGER.isWarnEnabled()) {
-					LOGGER.warn("** Null entity name for DataRow, can't resolve sub descriptor for "
-							+ descriptor.getEntity().getName());
-					return descriptor;
+					LOGGER.warn("** Null entity name for DataRow, can't resolve sub descriptor for {}",
+							descriptor.getEntity().getName());
 				}
+				return descriptor;
 			}
 
 			return context.getEntityResolver().getClassDescriptor(entityName);
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/PrefetchProcessorJointNode.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/PrefetchProcessorJointNode.java
index 651124c..ccf8a46 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/PrefetchProcessorJointNode.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/PrefetchProcessorJointNode.java
@@ -139,12 +139,10 @@ class PrefetchProcessorJointNode extends PrefetchProcessorNode {
             row.put(column.getName(), flatRow.get(column.getDataRowKey()));
         }
 
-        // since JDBC row reader won't inject JOINED entity name, we have to
-        // detect it here...
-
+        // since JDBC row reader won't inject JOINED entity name, we have to detect it here...
         ClassDescriptor descriptor = resolver.getDescriptor();
         ObjEntity entity = descriptor.getEntityInheritanceTree().entityMatchingRow(row);
-        row.setEntityName(entity.getName());
+        row.setEntityName(entity == null ? null : entity.getName());
         return row;
     }
 


Mime
View raw message