Nadav Har'El created CASSANDRA-21738:
----------------------------------------

             Summary: NullPointerException when an empty value is bound to 
USING TIMESTAMP
                 Key: CASSANDRA-21738
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21738
             Project: Apache Cassandra
          Issue Type: Bug
            Reporter: Nadav Har'El


When a prepared statement's {{USING TIMESTAMP ?}} bind marker is given an empty 
(zero-length) value, the request fails with a server error caused by a 
NullPointerException:

{code:sql}
CREATE TABLE ks.t (k int PRIMARY KEY, v int);
-- prepare, and bind ? to an empty (0-byte) value:
INSERT INTO ks.t (k, v) VALUES (1, 1) USING TIMESTAMP ?;
{code}

{noformat}
Server error: java.lang.NullPointerException: Cannot invoke 
"java.lang.Long.longValue()" because the return value of ... is null
{noformat}

Reproduced on Cassandra 5.0.9 and 6.0-alpha2.

CASSANDRA-17822 fixed the same NPE for {{USING TTL ?}}: 
{{Attributes.getTimeToLive()}} now treats an empty value like null, i.e. no TTL 
({{InsertTest.testEmptyTTL}}). But {{Attributes.getTimestamp()}} has no such 
check. It validates the empty buffer, and {{LongType.instance.compose()}} 
returns null for it, which is then unboxed into a long.

Expected: an InvalidRequestException, like the one for a null value ("Invalid 
null value of timestamp"), instead of a server error.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to