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
This commit is contained in:
Josh Cummings 2019-03-26 15:20:49 -06:00
parent 281ccff907
commit 2daed8c003
No known key found for this signature in database
GPG Key ID: 49EF60DD7FF83443
1 changed files with 4 additions and 3 deletions

View File

@ -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();