KeycloakErrorHandler NullPointerException String.toLowerCase() because message is null

Closes #22958
Signed-off-by: Douglas Palmer <dpalmer@redhat.com>
This commit is contained in:
Douglas Palmer 2023-11-15 10:39:23 -08:00 committed by Alexander Schwartz
parent fe48afc1dc
commit f9665acc29

View file

@ -81,7 +81,7 @@ public class PersistenceExceptionConverter implements InvocationHandler {
public static ModelException convert(Throwable t) { public static ModelException convert(Throwable t) {
final Predicate<Throwable> checkDuplicationMessage = throwable -> { final Predicate<Throwable> checkDuplicationMessage = throwable -> {
final String message = throwable.getCause() != null ? throwable.getCause().getMessage() : throwable.getMessage(); final String message = throwable.getCause() != null ? throwable.getCause().getMessage() : throwable.getMessage();
return message.toLowerCase().contains("duplicate"); return message == null ? false : message.toLowerCase().contains("duplicate");
}; };
Predicate<Throwable> throwModelDuplicateEx = throwable -> Predicate<Throwable> throwModelDuplicateEx = throwable ->