Skip to content

Commit 06bac4c

Browse files
Use pattern matching
Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent 174f17e commit 06bac4c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/BearerTokenAuthenticationEntryPoint.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public void commence(HttpServletRequest request, HttpServletResponse response,
6565
if (this.realmName != null) {
6666
parameters.put("realm", this.realmName);
6767
}
68-
if (authException instanceof OAuth2AuthenticationException) {
69-
OAuth2Error error = ((OAuth2AuthenticationException) authException).getError();
68+
if (authException instanceof OAuth2AuthenticationException oAuth2AuthenticationException) {
69+
OAuth2Error error = oAuth2AuthenticationException.getError();
7070
parameters.put("error", error.getErrorCode());
7171
if (StringUtils.hasText(error.getDescription())) {
7272
parameters.put("error_description", error.getDescription());
@@ -78,7 +78,7 @@ public void commence(HttpServletRequest request, HttpServletResponse response,
7878
if (StringUtils.hasText(bearerTokenError.getScope())) {
7979
parameters.put("scope", bearerTokenError.getScope());
8080
}
81-
status = ((BearerTokenError) error).getHttpStatus();
81+
status = bearerTokenError.getHttpStatus();
8282
}
8383
}
8484
String wwwAuthenticate = computeWWWAuthenticateHeaderValue(parameters);

0 commit comments

Comments
 (0)