This is an automated email from the ASF dual-hosted git repository. radcortez pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomee.git
commit e0eea232387cfdbc0c4ddc81c7a250dc38a6a3d8 Author: Roberto Cortez <[email protected]> AuthorDate: Tue Jan 8 18:54:07 2019 +0000 TOMEE-2365 - Improved exception message on multiple HttpAuthenticationMechanism. --- .../TomEESecurityServletAuthenticationMechanismMapper.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tomee/tomee-security/src/main/java/org/apache/tomee/security/cdi/TomEESecurityServletAuthenticationMechanismMapper.java b/tomee/tomee-security/src/main/java/org/apache/tomee/security/cdi/TomEESecurityServletAuthenticationMechanismMapper.java index d054783..2f2979c 100644 --- a/tomee/tomee-security/src/main/java/org/apache/tomee/security/cdi/TomEESecurityServletAuthenticationMechanismMapper.java +++ b/tomee/tomee-security/src/main/java/org/apache/tomee/security/cdi/TomEESecurityServletAuthenticationMechanismMapper.java @@ -32,6 +32,9 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; +import static java.util.stream.Collectors.toList; +import static org.apache.commons.lang3.StringUtils.substringBefore; + @ApplicationScoped public class TomEESecurityServletAuthenticationMechanismMapper { private final Map<String, HttpAuthenticationMechanism> servletAuthenticationMapper = new ConcurrentHashMap<>(); @@ -69,7 +72,13 @@ public class TomEESecurityServletAuthenticationMechanismMapper { if (availableBeans.size() == 1) { defaultAuthenticationMechanism.setDelegate(availableBeans.iterator().next()); } else if (availableBeans.size() > 1) { - throw new IllegalStateException(); + throw new IllegalStateException( + "Multiple HttpAuthenticationMechanism found " + + availableBeans.stream() + .map(b -> substringBefore(b.getClass().getSimpleName(), "$$")) + .collect(toList()) + " " + + "without a @WebServlet association. " + + "Deploy a single one for the application, or associate it with a @WebServlet."); } }
