Skip to content

Commit 2daed8c

Browse files
committed
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
1 parent 281ccff commit 2daed8c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

web/src/main/java/org/springframework/security/web/server/transport/HttpsRedirectWebFilter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ private URI createRedirectUri(ServerWebExchange exchange) {
102102
UriComponentsBuilder.fromUri(exchange.getRequest().getURI());
103103

104104
if (port > 0) {
105-
builder.port(Optional.ofNullable(this.portMapper.lookupHttpsPort(port))
106-
.orElseThrow(() -> new IllegalStateException(
107-
"HTTP Port '" + port + "' does not have a corresponding HTTPS Port")));
105+
Optional.ofNullable(this.portMapper.lookupHttpsPort(port))
106+
.map(builder::port)
107+
.orElseThrow(() -> new IllegalStateException(
108+
"HTTP Port '" + port + "' does not have a corresponding HTTPS Port"));
108109
}
109110

110111
return builder.scheme("https").build().toUri();

0 commit comments

Comments
 (0)