cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: CAY-1997 Difference in NULL handling inside the path between PropertyUtils and DataObject.readNestedProperty
Date Thu, 02 Apr 2015 13:28:39 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 4bb5c912d -> cc3dba58a


CAY-1997 Difference in NULL handling inside the path between PropertyUtils and DataObject.readNestedProperty


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

Branch: refs/heads/master
Commit: cc3dba58ac86d44709780bb7184311035a7e9667
Parents: 4bb5c91
Author: aadamchik <aadamchik@apache.org>
Authored: Thu Apr 2 14:43:29 2015 +0300
Committer: aadamchik <aadamchik@apache.org>
Committed: Thu Apr 2 16:28:31 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/cayenne/reflect/PropertyUtils.java    |  3 +--
 .../org/apache/cayenne/reflect/PropertyUtilsTest.java     | 10 ++++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/cc3dba58/cayenne-server/src/main/java/org/apache/cayenne/reflect/PropertyUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/reflect/PropertyUtils.java b/cayenne-server/src/main/java/org/apache/cayenne/reflect/PropertyUtils.java
index 505a19b..9ce633a 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/reflect/PropertyUtils.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/reflect/PropertyUtils.java
@@ -322,8 +322,7 @@ public class PropertyUtils {
 			Object value = object;
 			for (Accessor accessor : accessors) {
 				if (value == null) {
-					throw new IllegalArgumentException("Null object at the end of the segment '" + accessor.getName()
-							+ "'");
+					return null;
 				}
 
 				value = accessor.getValue(value);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/cc3dba58/cayenne-server/src/test/java/org/apache/cayenne/reflect/PropertyUtilsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/reflect/PropertyUtilsTest.java
b/cayenne-server/src/test/java/org/apache/cayenne/reflect/PropertyUtilsTest.java
index 8c8765d..6c88531 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/reflect/PropertyUtilsTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/reflect/PropertyUtilsTest.java
@@ -77,6 +77,16 @@ public class PropertyUtilsTest {
 		accessor.setValue(o2, b1);
 		assertSame(b1, o2.getRelated().getByteArrayField());
 	}
+	
+	@Test
+	public void testCreateAccessorNested_Null() {
+
+		Accessor accessor = PropertyUtils.createAccessor(TstJavaBean.class, "related.byteArrayField");
+		assertNotNull(accessor);
+
+		TstJavaBean o1 = createBean();
+		assertNull(accessor.getValue(o1));
+	}
 
 	@Test
 	public void testGetProperty() {


Mime
View raw message