Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-23295

Possible NPE when on getting predicate literal list when dynamic values are not available

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-alpha-1
    • storage-api
    • None

    Description

      getLiteralList() in SearchArgumentImpl$PredicateLeafImpl returns null if dynamic values are not available.

      @Override
      public List<Object> getLiteralList() {
        if (literalList != null && literalList.size() > 0 && literalList.get(0) instanceof LiteralDelegate) {
          List<Object> newLiteraList = new ArrayList<Object>();
          try {
            for (Object litertalObj : literalList) {
              Object literal = ((LiteralDelegate) litertalObj).getLiteral();
              if (literal != null) {
                newLiteraList.add(literal);
              }
            }
          } catch (NoDynamicValuesException err) {
            LOG.debug("Error while retrieving literalList, returning null", err);
            return null;
          }
          return newLiteraList;
        }
        return literalList;
      } 

       

      There are multiple call sites where the return value is used without a null check. E.g:  leaf.getLiteralList().stream(). 

       

      The return null was added as part of HIVE-18827 to avoid having an unimportant warning message when dynamic values have not been delivered yet.

       

      sershe, jdere, I propose return an empty list instead of null in a case like this. What do you think?

      Attachments

        1. HIVE-23295.1.patch
          0.9 kB
          Attila Magyar

        Activity

          People

            amagyar Attila Magyar
            amagyar Attila Magyar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: