Skip to content

Commit cf0f459

Browse files
zzccctvmichaeljmarshall
authored andcommitted
[improve][broker] Unreasonable AuthenticationException reference (apache#18502)
(cherry picked from commit e5e5852)
1 parent f4c2d9d commit cf0f459

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public AuthenticationService(ServiceConfiguration conf) throws PulsarServerExcep
8787

8888
public String authenticateHttpRequest(HttpServletRequest request, AuthenticationDataSource authData)
8989
throws AuthenticationException {
90-
AuthenticationException authenticationException = null;
9190
String authMethodName = request.getHeader(AuthenticationFilter.PULSAR_AUTH_METHOD_NAME);
9291

9392
if (authMethodName != null) {
@@ -108,8 +107,6 @@ public String authenticateHttpRequest(HttpServletRequest request, Authentication
108107
LOG.debug("Authentication failed for provider " + providerToUse.getAuthMethodName() + " : "
109108
+ e.getMessage(), e);
110109
}
111-
// Store the exception so we can throw it later instead of a generic one
112-
authenticationException = e;
113110
throw e;
114111
}
115112
} else {
@@ -133,11 +130,7 @@ public String authenticateHttpRequest(HttpServletRequest request, Authentication
133130
return anonymousUserRole;
134131
}
135132
// If at least a provider was configured, then the authentication needs to be provider
136-
if (authenticationException != null) {
137-
throw authenticationException;
138-
} else {
139-
throw new AuthenticationException("Authentication required");
140-
}
133+
throw new AuthenticationException("Authentication required");
141134
} else {
142135
// No authentication required
143136
return "<none>";

0 commit comments

Comments
 (0)