CQL fromJson(null) throws NullPointerException patch by Edward Ribeiro; reviewed by jasobrown for CASSANDRA-13891
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2e5e11d6 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2e5e11d6 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2e5e11d6 Branch: refs/heads/cassandra-3.0 Commit: 2e5e11d66d41038bee8d2f81eb013f735d233def Parents: ac77e5e Author: Edward Ribeiro <edward.ribe...@gmail.com> Authored: Wed Apr 4 14:18:01 2018 -0300 Committer: Jason Brown <jasedbr...@gmail.com> Committed: Thu Apr 5 06:10:59 2018 -0700 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/cql3/functions/FunctionCall.java | 2 ++ .../apache/cassandra/cql3/validation/entities/JsonTest.java | 7 +++++++ 3 files changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/2e5e11d6/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 4828517..527975c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.2.13 + * CQL fromJson(null) throws NullPointerException (CASSANDRA-13891) * Fix query pager DEBUG log leak causing hit in paged reads throughput (CASSANDRA-14318) * Backport circleci yaml (CASSANDRA-14240) Merged from 2.1: http://git-wip-us.apache.org/repos/asf/cassandra/blob/2e5e11d6/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java b/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java index 4f53c98..323f1bb 100644 --- a/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java +++ b/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java @@ -98,6 +98,8 @@ public class FunctionCall extends Term.NonTerminal private static Term.Terminal makeTerminal(Function fun, ByteBuffer result, int version) throws InvalidRequestException { + if (result == null) + return null; if (!(fun.returnType() instanceof CollectionType)) return new Constants.Value(result); http://git-wip-us.apache.org/repos/asf/cassandra/blob/2e5e11d6/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java index 0f29928..46cdd52 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java @@ -247,6 +247,13 @@ public class JsonTest extends CQLTester // handle nulls execute("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, null); + assertRows(execute("SELECT k, asciival FROM %s WHERE k = ?", 0), row(0, null)); + + execute("INSERT INTO %s (k, frozenmapval) VALUES (?, fromJson(?))", 0, null); + assertRows(execute("SELECT k, frozenmapval FROM %s WHERE k = ?", 0), row(0, null)); + + execute("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, null); + assertRows(execute("SELECT k, udtval FROM %s WHERE k = ?", 0), row(0, null)); // ================ ascii ================ execute("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\"ascii text\""); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org