suiryc commented on a change in pull request #114: HTTPCORE-573 
FileContentDecoder don't always enforce the maximum number of bytes to transfer
URL: 
https://github.com/apache/httpcomponents-core/pull/114#discussion_r269553881
 
 

 ##########
 File path: 
httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
 ##########
 @@ -93,8 +93,9 @@ public long transfer(
 
         long bytesRead;
         if (this.buffer.hasData()) {
+            final int maxLen = this.buffer.length();
             dst.position(position);
-            bytesRead = this.buffer.read(dst);
+            bytesRead = this.buffer.read(dst, count < maxLen ? (int)count : 
maxLen);
 
 Review comment:
   I thought that casting was enough because it is only done when `count < 
maxLen` where `maxLen` is already an `int` (and thus should make `count <= 
Integer.MAX_VALUE`).
   In this case do you think it's better to make it more explicit as you 
suggest ? (and also in `LengthDelimitedDecoder`)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to