Skip to content

Commit 8eac7a9

Browse files
shin-mallangmhalbritter
authored andcommitted
Remove duplicate code in NettyWebServerFactoryCustomizer
Since the PropertyMapper's alwaysApplyingWhenNonNull() has already been called, the subsequent whenNonNull() is unnecessary. See gh-37434
1 parent 578b464 commit 8eac7a9

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public void customize(NettyReactiveWebServerFactory factory) {
6565
.to((maxKeepAliveRequests) -> customizeMaxKeepAliveRequests(factory, maxKeepAliveRequests));
6666
if (this.serverProperties.getHttp2() != null && this.serverProperties.getHttp2().isEnabled()) {
6767
map.from(this.serverProperties.getMaxHttpRequestHeaderSize())
68-
.whenNonNull()
6968
.to((size) -> customizeHttp2MaxHeaderSize(factory, size.toBytes()));
7069
}
7170
customizeRequestDecoder(factory, map);
@@ -87,24 +86,18 @@ private void customizeConnectionTimeout(NettyReactiveWebServerFactory factory, D
8786
private void customizeRequestDecoder(NettyReactiveWebServerFactory factory, PropertyMapper propertyMapper) {
8887
factory.addServerCustomizers((httpServer) -> httpServer.httpRequestDecoder((httpRequestDecoderSpec) -> {
8988
propertyMapper.from(this.serverProperties.getMaxHttpRequestHeaderSize())
90-
.whenNonNull()
9189
.to((maxHttpRequestHeader) -> httpRequestDecoderSpec
9290
.maxHeaderSize((int) maxHttpRequestHeader.toBytes()));
9391
ServerProperties.Netty nettyProperties = this.serverProperties.getNetty();
9492
propertyMapper.from(nettyProperties.getMaxInitialLineLength())
95-
.whenNonNull()
9693
.to((maxInitialLineLength) -> httpRequestDecoderSpec
9794
.maxInitialLineLength((int) maxInitialLineLength.toBytes()));
9895
propertyMapper.from(nettyProperties.getH2cMaxContentLength())
99-
.whenNonNull()
10096
.to((h2cMaxContentLength) -> httpRequestDecoderSpec
10197
.h2cMaxContentLength((int) h2cMaxContentLength.toBytes()));
10298
propertyMapper.from(nettyProperties.getInitialBufferSize())
103-
.whenNonNull()
10499
.to((initialBufferSize) -> httpRequestDecoderSpec.initialBufferSize((int) initialBufferSize.toBytes()));
105-
propertyMapper.from(nettyProperties.isValidateHeaders())
106-
.whenNonNull()
107-
.to(httpRequestDecoderSpec::validateHeaders);
100+
propertyMapper.from(nettyProperties.isValidateHeaders()).to(httpRequestDecoderSpec::validateHeaders);
108101
return httpRequestDecoderSpec;
109102
}));
110103
}

0 commit comments

Comments
 (0)