From 2daed8c0033e0a17199dfc3b4650159a03aa1337 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Tue, 26 Mar 2019 15:20:49 -0600 Subject: [PATCH] Readability Polish Heavily nested parentheses and lots of indentation can get hard to read, so we should simplify this where we can. Issue: gh-6639 --- .../web/server/transport/HttpsRedirectWebFilter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/src/main/java/org/springframework/security/web/server/transport/HttpsRedirectWebFilter.java b/web/src/main/java/org/springframework/security/web/server/transport/HttpsRedirectWebFilter.java index d0b7b49846..99d72a22be 100644 --- a/web/src/main/java/org/springframework/security/web/server/transport/HttpsRedirectWebFilter.java +++ b/web/src/main/java/org/springframework/security/web/server/transport/HttpsRedirectWebFilter.java @@ -102,9 +102,10 @@ public final class HttpsRedirectWebFilter implements WebFilter { UriComponentsBuilder.fromUri(exchange.getRequest().getURI()); if (port > 0) { - builder.port(Optional.ofNullable(this.portMapper.lookupHttpsPort(port)) - .orElseThrow(() -> new IllegalStateException( - "HTTP Port '" + port + "' does not have a corresponding HTTPS Port"))); + Optional.ofNullable(this.portMapper.lookupHttpsPort(port)) + .map(builder::port) + .orElseThrow(() -> new IllegalStateException( + "HTTP Port '" + port + "' does not have a corresponding HTTPS Port")); } return builder.scheme("https").build().toUri();