diff --git a/web/src/main/java/org/springframework/security/web/server/savedrequest/CookieServerRequestCache.java b/web/src/main/java/org/springframework/security/web/server/savedrequest/CookieServerRequestCache.java index 0c9302a70d..730994548b 100644 --- a/web/src/main/java/org/springframework/security/web/server/savedrequest/CookieServerRequestCache.java +++ b/web/src/main/java/org/springframework/security/web/server/savedrequest/CookieServerRequestCache.java @@ -81,10 +81,10 @@ public class CookieServerRequestCache implements ServerRequestCache { .map((m) -> exchange.getResponse()) .map(ServerHttpResponse::getCookies) .doOnNext((cookies) -> { - ResponseCookie.ResponseCookieBuilder redirectUriCookie = createRedirectUriCookieBuilder( - exchange.getRequest()); - this.cookieCustomizer.accept(redirectUriCookie); - cookies.add(REDIRECT_URI_COOKIE_NAME, redirectUriCookie.build()); + ResponseCookie.ResponseCookieBuilder builder = createRedirectUriCookieBuilder(exchange.getRequest()); + this.cookieCustomizer.accept(builder); + ResponseCookie redirectUriCookie = builder.build(); + cookies.add(REDIRECT_URI_COOKIE_NAME, redirectUriCookie); logger.debug(LogMessage.format("Request added to Cookie: %s", redirectUriCookie)); }) .then();