Skip to content

Commit

Permalink
HV-2001 Do not include impl classes of Validator and factory among be…
Browse files Browse the repository at this point in the history
…an types if they come from HV itself
  • Loading branch information
marko-bekhta committed Jul 23, 2024
1 parent 3538292 commit ed9b051
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.inject.spi.Bean;
Expand Down Expand Up @@ -44,6 +46,11 @@ public ValidatorBean(BeanManager beanManager, Bean<?> validatorFactoryBean,
this.types = Collections.unmodifiableSet(
CollectionHelper.<Type>newHashSet(
ClassHierarchyHelper.getHierarchy( validationProviderHelper.getValidatorBeanClass() )
.stream()
// We do not include impl class of a validator if it comes from Hibernate Validator.
// In this case we only want to share the interfaces:
.filter( c -> !( validationProviderHelper.isHibernateValidator() && c.equals( validationProviderHelper.getValidatorBeanClass() ) ) )
.collect( Collectors.toSet() )
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public ValidatorFactoryBean(BeanManager beanManager, ValidationProviderHelper va
this.types = Collections.unmodifiableSet(
CollectionHelper.<Type>newHashSet(
ClassHierarchyHelper.getHierarchy( validationProviderHelper.getValidatorFactoryBeanClass() )
.stream()
// We do not include impl class of a validator factory if it comes from Hibernate Validator.
// In this case we only want to share the interfaces:
.filter( c -> !( validationProviderHelper.isHibernateValidator() && c.equals( validationProviderHelper.getValidatorFactoryBeanClass() ) ) )
.collect( Collectors.toSet() )
)
);
}
Expand Down
4 changes: 0 additions & 4 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,6 @@
org.hibernate.validator.*.internal.* to org.hibernate.validator.cdi;
*;
</exports>
<opens>
<!-- As both Validator and ValidatorFactory have to be accessible by CDI ... -->
org.hibernate.validator.internal.engine;
</opens>
<uses>
jakarta.validation.valueextraction.ValueExtractor;
jakarta.validation.ConstraintValidator
Expand Down

0 comments on commit ed9b051

Please sign in to comment.