aizu-m opened a new pull request, #124:
URL: https://github.com/apache/poi-xmlbeans/pull/124

       org.opentest4j.AssertionFailedError: xs:int and xs:long '-1' hash 
differently ==> expected: <-1> but was: <-20>
   
   Turned up while sweeping valueEquals against valueHashCode over the built-in 
types, after reading XMLBEANS-658. Every mismatch involved one of the five 
types backed by JavaIntHolder: int, short, byte, unsignedShort, unsignedByte. 
The other three xsd:decimal holders agree with each other.
   
   JavaLongHolder, JavaIntegerHolder and JavaDecimalHolder hash a long-range 
value as `(longval >> 32) * 19 + longval`, and all four holders carry the same 
comment about being carefully aligned. JavaIntHolder returns the raw int 
instead. For a non-negative value the two forms agree. For a negative one the 
sign-extended high word is -1, so the long form subtracts a further 19 and the 
hashes diverge.
   
   The consequence is in xs:unique and xs:key. IdentityConstraint keeps field 
values in a `LinkedHashSet<XmlObjectList>`, and XmlObjectList hashes with 
valueHashCode while comparing with valueEquals, so `contains()` misses a 
duplicate whose two occurrences have different decimal-derived types:
   
       <t:root><t:i>-5</t:i><t:l>-5</t:l></t:root>   validates clean
       <t:root><t:i>5</t:i><t:l>5</t:l></t:root>     
cvc-identity-constraint.4.1: Duplicate key '5' for unique constraint 'u@urn:t'
   
   Same constraint, same value, only the sign decides whether it is reported. 
Both are reported after the change, and non-negative values hash exactly as 
they did before.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to