Uploaded image for project: 'Apache Storm'
  1. Apache Storm
  2. STORM-1594

org.apache.storm.tuple.Fields can throw NPE if given invalid field in selector

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0, 1.1.0, 1.0.3
    • Component/s: storm-core
    • Labels:

      Description

      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.

      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;
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lujinhong lujinhong
                Reporter:
                abellina Alessandro Bellina
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: