oscerd commented on code in PR #26892:
URL: https://github.com/apache/camel/pull/26892#discussion_r4122364484


##########
core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java:
##########
@@ -266,7 +269,7 @@ public static int copy(
             // flush at end, if we didn't do it during the writing
             output.flush();
         }
-        return total;
+        return (int) Math.min(total, Integer.MAX_VALUE);

Review Comment:
   Agreed, and thanks for tracing the caller. 
`DefaultHttpBinding.doWriteDirectResponse` sizes a non-chunked response with 
`int len = copyStream(...)` and then calls `response.setContentLength(len)`. 
Above 2 GiB that was a wrapped negative value before this change and is 
`Integer.MAX_VALUE` after it. Both are wrong, as you say.
   
   That is pre-existing, and it lives in camel-http-common rather than 
camel-util, so I'll keep this PR to the counter fix. The follow-up would take 
the length as a `long` from the `CachedOutputStream` and call 
`setContentLengthLong`. I'll file a separate Jira for it.
   
   _Claude Code on behalf of @oscerd_
   



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