Closed glassfishrobot closed 8 years ago
Reported by JoepWeijers
lexi said: Fixed in https://github.com/highsource/jaxb2-basics/issues/22.
Was assigned to super_glassfish
This issue was imported from java.net JIRA JAXB2_COMMONS-37
Marked as fixed on Thursday, December 24th 2015, 12:59:31 am
The method JAXBEqualsStrategy.equals(ObjectLocator leftLocator, ObjectLocator rightLocator, Object lhs, Object rhs) is not symmetric when comparing an Enum and a Concrete class, thus it violates the contract of Object.equals().
If lhs is an Enum and rhs is not an Enum, a ClassCastException to java.lang.Enum is thrown. If rhs is not an enum and lhs is an Enum, no exception is thrown and the method correctly compares lhs and rhs. I observed this behaviour in 0.6.5 and verified that it also occurs in the latest released version 0.9.2.
The problem is in DefaultEqualsStrategy.equalsInternal(ObjectLocator leftLocator, ObjectLocator rightLocator, Object lhs, Object rhs):
If the left hand side of the equals is an Enum, we assume that the right is an Enum as well, which is incorrect in the example case, resulting in the ClassCastException.
Environment
java8u31, using maven
Affected Versions
[current]