You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2012/09/18 21:01:18 UTC
svn commit: r1387321 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt
httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
Author: olegk
Date: Tue Sep 18 19:01:17 2012
New Revision: 1387321
URL: http://svn.apache.org/viewvc?rev=1387321&view=rev
Log:
HTTPCORE-312: LengthDelimitedEncoder incorrectly handles messages larger than 2GB
Modified:
httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=1387321&r1=1387320&r2=1387321&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Tue Sep 18 19:01:17 2012
@@ -1,5 +1,8 @@
Changes since 4.2.1
+* [HTTPCORE-312] NIO length delimited content encoder incorrectly handles messages larger than 2GB.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
* [HTTPCORE-310] Fixed regression in DefaultConnectionReuseStrategy causing it to incorrectly
flag connections as non-reusable after a 204, 205 or 304 response.
Contributed by Oleg Kalnichevski <olegk at apache.org>
@@ -18,6 +21,7 @@ Changes since 4.2.1
* [HTTPCORE-303] ContentType made Serializable.
Contributed by Oleg Kalnichevski <olegk at apache.org>
+
Release 4.2.1
-------------------
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java?rev=1387321&r1=1387320&r2=1387321&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java Tue Sep 18 19:01:17 2012
@@ -75,12 +75,12 @@ public class LengthDelimitedEncoder exte
return 0;
}
assertNotCompleted();
- int lenRemaining = (int) (this.contentLength - this.len);
+ int chunk = (int) Math.min((this.contentLength - this.len), Integer.MAX_VALUE);
int bytesWritten;
- if (src.remaining() > lenRemaining) {
+ if (src.remaining() > chunk) {
int oldLimit = src.limit();
- int newLimit = oldLimit - (src.remaining() - lenRemaining);
+ int newLimit = oldLimit - (src.remaining() - chunk);
src.limit(newLimit);
bytesWritten = this.channel.write(src);
src.limit(oldLimit);
@@ -106,13 +106,8 @@ public class LengthDelimitedEncoder exte
return 0;
}
assertNotCompleted();
- int lenRemaining = (int) (this.contentLength - this.len);
-
- long bytesWritten;
- if (count > lenRemaining) {
- count = lenRemaining;
- }
- bytesWritten = src.transferTo(position, count, this.channel);
+ long chunk = Math.min((this.contentLength - this.len), count);
+ long bytesWritten = src.transferTo(position, chunk, this.channel);
if (bytesWritten > 0) {
this.metrics.incrementBytesTransferred(bytesWritten);
}