Liron Levy created ORC-1291:
-------------------------------

             Summary: NullPointerException in TypeDescription
                 Key: ORC-1291
                 URL: https://issues.apache.org/jira/browse/ORC-1291
             Project: ORC
          Issue Type: Bug
          Components: Java
    Affects Versions: 1.8.0
            Reporter: Liron Levy


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

For example:

 
{code:java}
val orcSchema1 = TypeDescription.createStruct()
    .addField("a", TypeDescription.createString())
    .addField("b", TypeDescription.createDouble())
    .addField("c", TypeDescription.createBoolean())

println(orcSchema1.hashCode()) {code}
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:
{code:java}
  @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;
  } {code}
while version 1.8 has this:
{code:java}
  @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;
  } {code}
Primitive type description do not have children which means that hashCode 
cannot work on any TypeDescription (as it will surely have primitive types 
somewhere).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to