It's not really obvious to me how this could be tested more ellegantly... I hadn't enough time to investigate thoroughly why exactly in JSF environment the validation fails, but I think it is due to the fact that at some point soft references from <code>AnnotationMetaDataProvider.configuredBeans</code> gets removed and therefore there are two different location elements created for base class and super class (see the test case).
In order to test this, somehow the cache needs to be disabled. Did that in quite awful way, but at least the test case shows the problem.
Adding following to <code>ConstraintLocation</code> fixes the issue:
<code> @Override public boolean equals(Object o) { if ( this == o ) { return true; }
if ( o == null || getClass() != o.getClass() ) { return false; } ConstraintLocation that = (ConstraintLocation) o; if ( declaringClass != null ? !declaringClass.equals( that.declaringClass ) : that.declaringClass != null ) { return false; }
if ( member != null ? !member.equals( that.member ) : that.member != null ) { return false; }
return true; }
@Override public int hashCode() { int result = member != null ? member.hashCode() : 0; result = 31 * result + ( declaringClass != null ? declaringClass.hashCode() : 0 ); return result; }
</code>
|