You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/06/27 02:35:51 UTC

[jira] [Commented] (STORM-1594) org.apache.storm.tuple.Fields can throw NPE if given invalid field in selector

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

ASF GitHub Bot commented on STORM-1594:
---------------------------------------

GitHub user lujinhong opened a pull request:

    https://github.com/apache/storm/pull/1522

    [STORM-1594] org.apache.storm.tuple.Fields can throw NPE if given invalid field in selector

    fix STORM-1594.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/lujinhong/storm storm-1594

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/storm/pull/1522.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1522
    
----
commit bdf4ba5cb10a6af1db20f105f6cda2064b669548
Author: lujinhong <lu...@gmail.com>
Date:   2016-06-27T02:33:28Z

    fix STORM-1594

----


> org.apache.storm.tuple.Fields can throw NPE if given invalid field in selector
> ------------------------------------------------------------------------------
>
>                 Key: STORM-1594
>                 URL: https://issues.apache.org/jira/browse/STORM-1594
>             Project: Apache Storm
>          Issue Type: Bug
>          Components: storm-core
>            Reporter: Alessandro Bellina
>            Priority: Minor
>              Labels: npe
>
> In class org.apache.storm.tuple.Fields, the select method gets the index of the field to select from the first argument (selector) by using .get. It doesn't set this result to an Integer and check for null (Map.get returns null if the key is not found).
> When tuple.get happens, the parameter for tuple.get is an unboxed integer. The null cannot be unboxed to integer, causing an NPE. There is another method in Fields called fieldIndex which will throw an IllegalArgumentException in the case that the field in the selector isn't in the _index. 
> {code}
> public List<Object> select(Fields selector, List<Object> tuple) {
>     List<Object> ret = new ArrayList<>(selector.size());	
>     for(String s: selector) {
>         ret.add(tuple.get(_index.get(s)));	
>     }
>     return ret;
> }
> {code}



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