[
https://issues.apache.org/jira/browse/STORM-1594?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jungtaek Lim resolved STORM-1594.
---------------------------------
Resolution: Fixed
Assignee: lujinhong
Fix Version/s: 1.0.3
1.1.0
2.0.0
Thanks [~lujinhong], I merged into master, 1.x, 1.0.x branches.
> 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
> Assignee: lujinhong
> Priority: Minor
> Labels: npe
> Fix For: 2.0.0, 1.1.0, 1.0.3
>
>
> 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)