Copilot commented on code in PR #3425:
URL: https://github.com/apache/cxf/pull/3425#discussion_r3899894431


##########
core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java:
##########
@@ -713,7 +714,98 @@ public void testManyAttachmentHeaders() throws Exception {
         assertThrows("Failure expected on too many attachment headers", 
IOException.class, 
             () -> ad.initializeAttachments());
     }
+
+    @Test
+    public void testAttachmentHeaderSize() throws Exception {
+        final Random random = new Random();
+
+        StringBuilder sb = new StringBuilder(10000);
+        // Add many attachment headers
+        sb.append("------=_Part_34950_1098328613.1263781527359\n");
+        sb.append("Header:")
+            .append(random.ints('a', 'z')
+                .limit(500)
+                .collect(StringBuilder::new, StringBuilder::appendCodePoint, 
StringBuilder::append))
+            .append('\n');
+        sb.append("Content-Type: text/xml; charset=UTF-8\n")
+            .append("Content-Transfer-Encoding: binary\n")
+            .append("Content-Id: 
<318731183421.1263781527359.IBM.WEBSERVICES@auhpap02>\n")
+            .append('\n')
+            .append("<envelope/>\n");
+
+        msg = new MessageImpl();
+        msg.setContent(InputStream.class, new 
ByteArrayInputStream(sb.toString().getBytes(StandardCharsets.UTF_8)));
+        msg.put(Message.CONTENT_TYPE, "multipart/related");
+        AttachmentDeserializer ad = new AttachmentDeserializer(msg);

Review Comment:
   These new tests rely on the global default header limit (which can be 
overridden via the system property 
`org.apache.cxf.attachment-max-header-size`). If that property is set to a 
higher value in CI or a developer environment, this test will stop asserting 
the intended behavior. Set `AttachmentDeserializer.ATTACHMENT_MAX_HEADER_SIZE` 
explicitly on the message to make the test deterministic and directly validate 
the property handling.
   
   This issue also appears in the following locations of the same file:
   - line 768
   - line 800



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

Reply via email to