in bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java [188:216]
public void addBValBeans(final @Observes AfterBeanDiscovery afterBeanDiscovery, final BeanManager beanManager) {
if (factory != null && factory.optional().isPresent()) { // cleanup cache used to discover ValidateOnException before factory is recreated
factory.get().close();
}
if (config instanceof ConfigurationImpl) {
((ConfigurationImpl) config).releaseDeferredBootstrapOverrides();
}
if (!validatorFactoryFound) {
try { // recreate the factory
factory = new Lazy<>(config::buildValidatorFactory);
afterBeanDiscovery.addBean(new ValidatorFactoryBean(factory));
validatorFactoryFound = true;
} catch (final ValidationException ve) {
//throw ve;
} catch (final Exception e) { // can throw an exception with custom providers
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
if (!validatorFound && validatorFactoryFound) {
try {
afterBeanDiscovery.addBean(new ValidatorBean(() -> CDI.current().select(ValidatorFactory.class).get().getValidator()));
validatorFound = true;
} catch (final ValidationException ve) {
throw ve;
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
}