mattpapp opened a new issue, #694:
URL: https://github.com/apache/wayang/issues/694

   Hi team,
   
   I was going through the code to get familiar and found a bug in 
`RecordType.hashCode()`.
   
   The `equals()` method uses `Arrays.equals()` to compare field names by 
content but `hashCode()` passes the `fieldNames` array directly to 
`Objects.hash()` which ends up using the array's identity hash instead of its 
content. So basically two RecordType instances with the same field names are 
considered equal but will give different hashcodes which is wrong.
   
   I wrote a small temp test locally as a sanity check:
   
       RecordType rt1 = new RecordType("x", "y", "z");
       RecordType rt2 = new RecordType("x", "y", "z");
   
       rt1.equals(rt2)  //true
       rt1.hashCode() == rt2.hashCode()  //false
   
       HashMap<RecordType, String> map = new HashMap<>();
       map.put(rt1, "z");
       map.get(rt2); //this will return null instead of "z"
   
   The fix is pretty simple: line 68 in `RecordType.java` just needs to wrap 
the array.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to