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