You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Benjamin Lerer (JIRA)" <ji...@apache.org> on 2015/03/31 12:19:53 UTC

[jira] [Commented] (CASSANDRA-9077) Deleting an element from a List which is null throws a NPE

    [ https://issues.apache.org/jira/browse/CASSANDRA-9077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14388346#comment-14388346 ] 

Benjamin Lerer commented on CASSANDRA-9077:
-------------------------------------------

I think we should provide as clear information as possible. By consequence, I am more in favor of the approach of the first patch.
Regarding the first patch I have the following comments:
* I think the messages should be {{"Attempted to set an element on a list which is null"}} and {{"Attempted to delete an element from a list which is null"}}. If we sometime talk about {{empty}} and other time about {{null}} it might confuse the user.
* It seems that operation like: {{UPDATE %s SET l = l - \['2'\] WHERE id = 'user'}} suffer from a similar problem
* Could you add some unit tests in {{CollectionsTest}} to verify the correct behavior for all those use cases?

> Deleting an element from a List which is null throws a NPE
> ----------------------------------------------------------
>
>                 Key: CASSANDRA-9077
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9077
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>            Reporter: dan jatnieks
>            Assignee: Jeff Jirsa
>            Priority: Minor
>         Attachments: 9077-stacktrace.log, cassandra-9077-option1.txt, cassandra-9077-option2.txt
>
>
> I am seeing an NPE on the latest 2.1 branch with this sequence of deletes from a list - first delete the entire list, then attempt to delete one element.
> I expected to see {{List index 0 out of bound, list has size 0}} but instead got an NPE.
> {noformat}
> ./bin/cqlsh
> Connected to Test Cluster at 127.0.0.1:9042.
> [cqlsh 5.0.1 | Cassandra 2.1.3-SNAPSHOT | CQL spec 3.2.0 | Native protocol v3]
> Use HELP for help.
> cqlsh> use frozen_collections ;
> cqlsh:frozen_collections> DROP TABLE IF EXISTS t;
> cqlsh:frozen_collections> CREATE TABLE t (id text PRIMARY KEY, l list<text>, s set<text>);
> cqlsh:frozen_collections> INSERT INTO t (id, l, s) VALUES ('user', ['1'], {'1'});
> cqlsh:frozen_collections>
> cqlsh:frozen_collections> DELETE l FROM t WHERE id ='user';
> cqlsh:frozen_collections> //INSERT INTO t (id, l) VALUES ('user', ['1']);
> cqlsh:frozen_collections> DELETE l[0] FROM t WHERE id = 'user';
> ServerError: <ErrorMessage code=0000 [Server error] message="java.lang.NullPointerException">
> cqlsh:frozen_collections>
> cqlsh:frozen_collections> DELETE s FROM t WHERE id ='user';
> cqlsh:frozen_collections> DELETE s['1'] FROM t WHERE id = 'user';
> {noformat}
> It appears the {{DELETE emails...}} directly followed by {{DELETE emails[0]...}} is the offending sequence. Either one alone works fine, as does adding an intervening insert/update.
> The same sequence performed on a Set rather than List works (as shown above).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)