Copilot commented on code in PR #61197:
URL: https://github.com/apache/doris/pull/61197#discussion_r2912864871


##########
fe/fe-core/src/main/java/org/apache/doris/httpv2/config/WebServerFactoryCustomizerConfig.java:
##########
@@ -40,6 +40,21 @@ public class WebServerFactoryCustomizerConfig implements 
WebServerFactoryCustomi
     @Override
     public void customize(ConfigurableJettyWebServerFactory factory) {
 
+        // Set HTTP header size for all connectors
+        factory.addServerCustomizers(server -> {
+            for (org.eclipse.jetty.server.Connector connector : 
server.getConnectors()) {
+                if (connector instanceof ServerConnector) {
+                    ServerConnector serverConnector = (ServerConnector) 
connector;

Review Comment:
   This can be simplified and made less error-prone by using pattern matching 
for `instanceof` (e.g., `if (connector instanceof ServerConnector 
serverConnector)`), and by avoiding the fully-qualified 
`org.eclipse.jetty.server.Connector` in-line if the file already has imports. 
This reduces verbosity and the chance of inconsistent type usage across the 
class.



##########
regression-test/suites/http_p0/test_large_http_header.groovy:
##########
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_large_http_header", "p0") {
+    def feHost = context.config.feHttpAddress
+    def (host, port) = feHost.split(":")
+
+    // Test with large HTTP header (100KB)
+    def largeHeaderValue = "x" * (100 * 1024)
+
+    def url = "http://${host}:${port}/api/health";
+
+    try {
+        def connection = new URL(url).openConnection()
+        connection.setRequestMethod("GET")
+        connection.setRequestProperty("X-Large-Header", largeHeaderValue)
+        connection.setConnectTimeout(5000)
+        connection.setReadTimeout(5000)
+
+        def responseCode = connection.getResponseCode()
+
+        // Should not return 431 (Request Header Fields Too Large)
+        assertTrue(responseCode != 431, "Should not return 431 error with 
large header")

Review Comment:
   This assertion can produce false positives (e.g., a 500/404 would pass). 
Since the PR description states the expected result is HTTP 200 after the fix, 
assert an explicit success response (e.g., `responseCode == 200`) so the 
regression test fails for other unexpected server errors.
   ```suggestion
           // Expect successful health check with HTTP 200
           assertTrue(responseCode == 200, "Expected HTTP 200 from health 
endpoint, but got ${responseCode}")
   ```



##########
regression-test/suites/http_p0/test_large_http_header.groovy:
##########
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_large_http_header", "p0") {
+    def feHost = context.config.feHttpAddress
+    def (host, port) = feHost.split(":")
+
+    // Test with large HTTP header (100KB)
+    def largeHeaderValue = "x" * (100 * 1024)
+
+    def url = "http://${host}:${port}/api/health";
+
+    try {
+        def connection = new URL(url).openConnection()
+        connection.setRequestMethod("GET")
+        connection.setRequestProperty("X-Large-Header", largeHeaderValue)
+        connection.setConnectTimeout(5000)
+        connection.setReadTimeout(5000)
+
+        def responseCode = connection.getResponseCode()

Review Comment:
   `openConnection()` returns `URLConnection` and the HTTP-specific 
APIs/resources are on `HttpURLConnection`. Consider explicitly casting to 
`HttpURLConnection` (or using `as HttpURLConnection`) and ensuring the 
connection is cleaned up (e.g., closing the input/error stream and calling 
`disconnect()` in a `finally`) to avoid resource leaks in the test runner.



##########
regression-test/suites/http_p0/test_large_http_header.groovy:
##########
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_large_http_header", "p0") {
+    def feHost = context.config.feHttpAddress
+    def (host, port) = feHost.split(":")
+
+    // Test with large HTTP header (100KB)
+    def largeHeaderValue = "x" * (100 * 1024)
+
+    def url = "http://${host}:${port}/api/health";
+
+    try {
+        def connection = new URL(url).openConnection()
+        connection.setRequestMethod("GET")
+        connection.setRequestProperty("X-Large-Header", largeHeaderValue)

Review Comment:
   `openConnection()` returns `URLConnection` and the HTTP-specific 
APIs/resources are on `HttpURLConnection`. Consider explicitly casting to 
`HttpURLConnection` (or using `as HttpURLConnection`) and ensuring the 
connection is cleaned up (e.g., closing the input/error stream and calling 
`disconnect()` in a `finally`) to avoid resource leaks in the test runner.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to