Skip to content

Commit

Permalink
Remove duplicate code in NettyWebServerFactoryCustomizer
Browse files Browse the repository at this point in the history
Since the PropertyMapper's alwaysApplyingWhenNonNull() has already been
called, the subsequent whenNonNull() is unnecessary.

See gh-37434
  • Loading branch information
shin-mallang authored and mhalbritter committed Sep 28, 2023
1 parent 578b464 commit 8eac7a9
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public void customize(NettyReactiveWebServerFactory factory) {
.to((maxKeepAliveRequests) -> customizeMaxKeepAliveRequests(factory, maxKeepAliveRequests));
if (this.serverProperties.getHttp2() != null && this.serverProperties.getHttp2().isEnabled()) {
map.from(this.serverProperties.getMaxHttpRequestHeaderSize())
.whenNonNull()
.to((size) -> customizeHttp2MaxHeaderSize(factory, size.toBytes()));
}
customizeRequestDecoder(factory, map);
Expand All @@ -87,24 +86,18 @@ private void customizeConnectionTimeout(NettyReactiveWebServerFactory factory, D
private void customizeRequestDecoder(NettyReactiveWebServerFactory factory, PropertyMapper propertyMapper) {
factory.addServerCustomizers((httpServer) -> httpServer.httpRequestDecoder((httpRequestDecoderSpec) -> {
propertyMapper.from(this.serverProperties.getMaxHttpRequestHeaderSize())
.whenNonNull()
.to((maxHttpRequestHeader) -> httpRequestDecoderSpec
.maxHeaderSize((int) maxHttpRequestHeader.toBytes()));
ServerProperties.Netty nettyProperties = this.serverProperties.getNetty();
propertyMapper.from(nettyProperties.getMaxInitialLineLength())
.whenNonNull()
.to((maxInitialLineLength) -> httpRequestDecoderSpec
.maxInitialLineLength((int) maxInitialLineLength.toBytes()));
propertyMapper.from(nettyProperties.getH2cMaxContentLength())
.whenNonNull()
.to((h2cMaxContentLength) -> httpRequestDecoderSpec
.h2cMaxContentLength((int) h2cMaxContentLength.toBytes()));
propertyMapper.from(nettyProperties.getInitialBufferSize())
.whenNonNull()
.to((initialBufferSize) -> httpRequestDecoderSpec.initialBufferSize((int) initialBufferSize.toBytes()));
propertyMapper.from(nettyProperties.isValidateHeaders())
.whenNonNull()
.to(httpRequestDecoderSpec::validateHeaders);
propertyMapper.from(nettyProperties.isValidateHeaders()).to(httpRequestDecoderSpec::validateHeaders);
return httpRequestDecoderSpec;
}));
}
Expand Down

0 comments on commit 8eac7a9

Please sign in to comment.