Uploaded image for project: 'ORC'
  1. ORC
  2. ORC-1291

NullPointerException in TypeDescription

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.8.0
    • 1.8.1
    • Java
    • None

    Description

      There's a null pointer exception in the cases where TypeDescription does not have children.

      For example:

       

      val orcSchema1 = TypeDescription.createStruct()
          .addField("a", TypeDescription.createString())
          .addField("b", TypeDescription.createDouble())
          .addField("c", TypeDescription.createBoolean())
      
      println(orcSchema1.hashCode()) 

      This will throw:

       

      java.lang.NullPointerException: Cannot invoke "java.util.List.hashCode()" because "this.children" is null

      As you can see version 1.7 had this code:

        @Override
        public int hashCode() {
          long result = category.ordinal() * 4241 + maxLength + precision * 13 + scale;
          if (children != null) {
            for(TypeDescription child: children) {
              result = result * 6959 + child.hashCode();
            }
          }
          return (int) result;
        } 

      while version 1.8 has this:

        @Override
        public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result + category.hashCode();
          result = prime * result + children.hashCode();
          result = prime * result + maxLength;
          result = prime * result + precision;
          result = prime * result + scale;
          return result;
        } 

      Primitive type description do not have children which means that hashCode cannot work on any TypeDescription (as it will surely have primitive types somewhere).

      Attachments

        Issue Links

          Activity

            People

              dongjoon Dongjoon Hyun
              liron-upstream Liron Levy
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: