cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [2/3] cayenne git commit: Missing check for null values
Date Thu, 15 Nov 2018 11:09:56 GMT
Missing check for null values


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

Branch: refs/heads/master
Commit: a42bcd7e1409e0c38a922b9f025f34c1b3b40689
Parents: b580bda
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Thu Nov 15 13:58:59 2018 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Thu Nov 15 13:58:59 2018 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/cayenne/exp/parser/ASTList.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/a42bcd7e/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTList.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTList.java b/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTList.java
index e9e4d56..74a99e4 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTList.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/exp/parser/ASTList.java
@@ -184,7 +184,7 @@ public class ASTList extends SimpleNode {
 			System.arraycopy((Object[]) value, 0, this.values, 0, size);
 		} else if (value instanceof Collection) {
 			Collection<?> c = (Collection<?>) value;
-			this.values = c.toArray(new Object[c.size()]);
+			this.values = c.toArray(new Object[0]);
 		} else if (value instanceof Iterator) {
 			List<Object> values = new ArrayList<>();
 			Iterator<?> it = (Iterator<?>) value;
@@ -201,6 +201,9 @@ public class ASTList extends SimpleNode {
 	}
 
 	private void convertValues() {
+		if(values == null) {
+			return;
+		}
 		for (int i = 0; i < values.length; i++) {
 			if (values[i] instanceof Persistent) {
 				values[i] = ((Persistent) values[i]).getObjectId();


Mime
View raw message