Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-6602

Null value dereference

Details

    • New, Patch Available

    Description

      In the file BoostQueryNode.java, getChild could be null and it is being dereferenced in the function toString().

      BoostQueryNode.java
        public QueryNode getChild() {
          List<QueryNode> children = getChildren();
      
          if (children == null || children.size() == 0) {
            return null;
          }
      
          return children.get(0);
      
        }
      BoostQueryNode.java
      public String toString() {
          return "<boost value='" + getValueString() + "'>" + "\n"
              + getChild().toString() + "\n</boost>";
        }
      

      Should we not check if getChild is valid?

      Probable fix
      String s = (getChild() != null) ? getChild().toString() : "null";
      return "<boost value='" + getValueString() + "'>" + "\n"
              + s + "\n</boost>";
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rmp91 Rishabh Patel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified