Skip to content

Commit

Permalink
Merge pull request #5405 from arjantijms/swallow_beanvalidation_excep…
Browse files Browse the repository at this point in the history
…tion

No need to swallow exception at that point.
  • Loading branch information
arjantijms authored Feb 21, 2024
2 parents 5f3bce0 + 89dd16d commit f9a9dcc
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -333,7 +334,7 @@ private void destroyInstances(ServletContext sc, FacesContext facesContext, List

/**
* If defaultValidatorIds is null, then no <default-validators> element appeared in any configuration file. In
* that case, add jakarta.faces.Bean if Bean Validation is available. If the <default-validators> appeared at
* that case, add jakarta.faces.Bean if Jakarta Validation is available. If the <default-validators> appeared at
* least once, don't add the default (and empty <default-validator> element disabled default validators)
*/
private void registerDefaultValidatorIds(FacesContext facesContext, Application application, LinkedHashSet<String> defaultValidatorIds) {
Expand Down Expand Up @@ -390,22 +391,19 @@ static boolean isBeanValidatorAvailable(FacesContext facesContext) {
result = true;
}
} catch (NamingException root) {
LOGGER.fine(() -> "Could not build a default Bean Validator factory: " + root.getMessage());
LOGGER.fine(() -> "Could not build a default Jakarta Validation ValidatorFactory: " + root.getMessage());
}

if (!result) {
try {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
factory.getValidator();
appMap.put(BeanValidator.VALIDATOR_FACTORY_KEY, factory);
result = true;
} catch (Throwable throwable) {
}
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
factory.getValidator();
appMap.put(BeanValidator.VALIDATOR_FACTORY_KEY, factory);
result = true;
}
}

} catch (Throwable t) { // CNFE or ValidationException or any other
LOGGER.fine("Unable to load Beans Validation");
LOGGER.fine("Unable to load Jakarta Validation");
}

appMap.put(beansValidationAvailabilityCacheKey, result);
Expand Down

0 comments on commit f9a9dcc

Please sign in to comment.