From e5e5852ee3ed5ae661104784c82a1b8f0cda321d Mon Sep 17 00:00:00 2001 From: zzccctv Date: Fri, 18 Nov 2022 11:42:52 +0800 Subject: [PATCH] [improve][broker] Unreasonable AuthenticationException reference (#18502) --- .../broker/authentication/AuthenticationService.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java index 0dedef64159c1..c63f5505e5974 100644 --- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java +++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java @@ -87,7 +87,6 @@ public AuthenticationService(ServiceConfiguration conf) throws PulsarServerExcep public String authenticateHttpRequest(HttpServletRequest request, AuthenticationDataSource authData) throws AuthenticationException { - AuthenticationException authenticationException = null; String authMethodName = request.getHeader(AuthenticationFilter.PULSAR_AUTH_METHOD_NAME); if (authMethodName != null) { @@ -108,8 +107,6 @@ public String authenticateHttpRequest(HttpServletRequest request, Authentication LOG.debug("Authentication failed for provider " + providerToUse.getAuthMethodName() + " : " + e.getMessage(), e); } - // Store the exception so we can throw it later instead of a generic one - authenticationException = e; throw e; } } else { @@ -133,11 +130,7 @@ public String authenticateHttpRequest(HttpServletRequest request, Authentication return anonymousUserRole; } // If at least a provider was configured, then the authentication needs to be provider - if (authenticationException != null) { - throw authenticationException; - } else { - throw new AuthenticationException("Authentication required"); - } + throw new AuthenticationException("Authentication required"); } else { // No authentication required return "";