Skip to content

Commit e76de93

Browse files
ngocnhan-tran1996jzheaux
authored andcommitted
Polish Optional usage
1 parent ffed4ea commit e76de93

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -395,9 +395,9 @@ private Mono<ClientResponse> exchangeAndHandleResponse(ClientRequest request, Ex
395395
}
396396

397397
private Mono<ClientRequest> mergeRequestAttributesIfNecessary(ClientRequest request) {
398-
if (!request.attribute(HTTP_SERVLET_REQUEST_ATTR_NAME).isPresent()
399-
|| !request.attribute(HTTP_SERVLET_RESPONSE_ATTR_NAME).isPresent()
400-
|| !request.attribute(AUTHENTICATION_ATTR_NAME).isPresent()) {
398+
if (request.attribute(HTTP_SERVLET_REQUEST_ATTR_NAME).isEmpty()
399+
|| request.attribute(HTTP_SERVLET_RESPONSE_ATTR_NAME).isEmpty()
400+
|| request.attribute(AUTHENTICATION_ATTR_NAME).isEmpty()) {
401401
return mergeRequestAttributesFromContext(request);
402402
}
403403
return Mono.just(request);

web/src/main/java/org/springframework/security/web/server/authentication/SwitchUserWebFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -228,7 +228,7 @@ private Mono<Authentication> attemptSwitchUser(Authentication currentAuthenticat
228228
@NonNull
229229
private Authentication attemptExitUser(Authentication currentAuthentication) {
230230
Optional<Authentication> sourceAuthentication = extractSourceAuthentication(currentAuthentication);
231-
if (!sourceAuthentication.isPresent()) {
231+
if (sourceAuthentication.isEmpty()) {
232232
this.logger.debug("Failed to find original user");
233233
throw noOriginalAuthenticationException();
234234
}

0 commit comments

Comments
 (0)