@NotNull doesn't work in 50% when annotated method is extended from multiple classes

Description

The problem is @NotNull does not work in around 50% when the annotated method is extended from multiple classes.

ClassA extends ClassB implements ClassC

ClassB has the method implementation including @NotNull and ClassC has the same method definition as interface.
Then, hibernate-validator can not distinguish the methods are different and put them into HashSet. Keys from those methods are same, so 2nd method put into the HashSet is not added (Key is not overwritten).

Please use reproducer I attached.

According to my debugging, org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataImpl.build() method adds org.hibernate.validator.internal.metadata.aggregated.ExecutableMetaData$Build into HashSet.
-----------
public BeanMetaDataImpl<T> build() {
Set<ConstraintMetaData> aggregatedElements = newHashSet();

for ( BuilderDelegate builder : builders ) {
aggregatedElements.addAll( builder.build() ); <------
}

return new BeanMetaDataImpl<T>(
beanClass,
defaultGroupSequence,
defaultGroupSequenceProvider,
aggregatedElements
);
}
----------
The ExecutableMetaData$Build for extended methods from different class and interface will generate same hashcode when it is put into HashSet. So 2nd ExecutableMetaData$Build key is not added to the HashSet.

Because those two ExecutableMetaData$Build for extended methods should be distinguished, proposed fix is....

  • Add info to distinguish defined class in ExecutableMetaData$Build

  • Modify ExecutableMetaData hashCode method to use not only parameterType but also other data to distinguish them.

Environment

hibernate-validator 5.1.3 — WebLogic 12.2
hibernate-validator 5.0.0 — Glassfish 4.1

Status

Assignee

Unassigned

Reporter

Masayoshi Takahashi

Labels

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

Priority

Major
Configure