Copilot commented on code in PR #6378:
URL: https://github.com/apache/shenyu/pull/6378#discussion_r3392858540
##########
shenyu-spring-boot-starter/shenyu-spring-boot-starter-gateway/src/main/java/org/apache/shenyu/springboot/starter/netty/ShenyuNettyWebServerConfiguration.java:
##########
@@ -156,6 +156,16 @@ public HttpServer apply(final HttpServer httpServer) {
return sniProcessor.apply(httpServer)
.runOn(LoopResources.create("shenyu-netty",
nettyHttpProperties.getSelectCount(), nettyHttpProperties.getWorkerCount(),
true))
.accessLog(nettyHttpProperties.getAccessLog())
+ // configure http request decoder
+ .httpRequestDecoder(spec -> {
+ NettyHttpProperties.HttpDecoderProperties decoder =
nettyHttpProperties.getHttpDecoder();
+ if (Objects.nonNull(decoder)) {
+
spec.maxInitialLineLength(decoder.getMaxInitialLineLength());
+ spec.maxHeaderSize(decoder.getMaxHeaderSize());
+ spec.maxChunkSize(decoder.getMaxChunkSize());
+ }
+ return spec;
+ })
Review Comment:
`nettyHttpProperties.getHttpDecoder()` is constructed by default, so the
`Objects.nonNull(decoder)` check is effectively redundant and adds extra
branching. If you keep `httpDecoder` non-null (e.g., via a null-safe setter),
this can be simplified to unconditional assignment of the decoder limits.
##########
shenyu-common/src/main/java/org/apache/shenyu/common/config/NettyHttpProperties.java:
##########
@@ -167,6 +169,24 @@ public void setAccessLog(final Boolean accessLog) {
this.accessLog = accessLog;
}
+ /**
+ * get httpDecoder properties.
+ *
+ * @return httpDecoder properties
+ */
+ public HttpDecoderProperties getHttpDecoder() {
+ return httpDecoder;
+ }
+
+ /**
+ * set httpDecoder properties.
+ *
+ * @param httpDecoder http decoder properties
+ */
+ public void setHttpDecoder(final HttpDecoderProperties httpDecoder) {
+ this.httpDecoder = httpDecoder;
+ }
Review Comment:
`httpDecoder` is initialized with a default instance, but
`setHttpDecoder(...)` currently allows assigning `null`, which breaks the
implied non-null contract. Consider keeping the property always non-null by
falling back to a new `HttpDecoderProperties` when the setter receives `null`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]