Polish Optional usage

This commit is contained in:
Tran Ngoc Nhan 2024-10-25 19:29:24 +07:00 committed by Josh Cummings
parent ffed4ea1dc
commit e76de931ce
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -395,9 +395,9 @@ public final class ServletOAuth2AuthorizedClientExchangeFilterFunction implement
}
private Mono<ClientRequest> mergeRequestAttributesIfNecessary(ClientRequest request) {
if (!request.attribute(HTTP_SERVLET_REQUEST_ATTR_NAME).isPresent()
|| !request.attribute(HTTP_SERVLET_RESPONSE_ATTR_NAME).isPresent()
|| !request.attribute(AUTHENTICATION_ATTR_NAME).isPresent()) {
if (request.attribute(HTTP_SERVLET_REQUEST_ATTR_NAME).isEmpty()
|| request.attribute(HTTP_SERVLET_RESPONSE_ATTR_NAME).isEmpty()
|| request.attribute(AUTHENTICATION_ATTR_NAME).isEmpty()) {
return mergeRequestAttributesFromContext(request);
}
return Mono.just(request);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -228,7 +228,7 @@ public class SwitchUserWebFilter implements WebFilter {
@NonNull
private Authentication attemptExitUser(Authentication currentAuthentication) {
Optional<Authentication> sourceAuthentication = extractSourceAuthentication(currentAuthentication);
if (!sourceAuthentication.isPresent()) {
if (sourceAuthentication.isEmpty()) {
this.logger.debug("Failed to find original user");
throw noOriginalAuthenticationException();
}