On 17 September 2012 20:58,  <[email protected]> wrote:
> Author: olegk
> Date: Mon Sep 17 19:58:17 2012
> New Revision: 1386795
>
> URL: http://svn.apache.org/viewvc?rev=1386795&view=rev
> Log:
> HTTPCORE-312: LengthDelimitedEncoder incorrectly handles messages larger than 
> 2GB
>
> Modified:
>     httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt
>     
> httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
>
> Modified: httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt
> URL: 
> http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt?rev=1386795&r1=1386794&r2=1386795&view=diff
> ==============================================================================
> --- httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt (original)
> +++ httpcomponents/httpcore/branches/4.2.x/RELEASE_NOTES.txt Mon Sep 17 
> 19:58:17 2012
> @@ -1,12 +1,18 @@
>  Release 4.2.2
>  -------------------
>
> -This is a maintenance release that fixes a number of bugs and regressions 
> found since 4.2.1.
> -Users of HttpCore 4.2 are encouraged to upgrade.
> +This is a maintenance release that fixes a number of bugs and regressions 
> found since 4.2.1
> +including a major bug in NIO module causing incorrectly handling of outgoing 
> Content-Length

s/in NIO/in the NIO/

s/incorrectly/incorrect/

> +delimited messages larger than 2GB.
> +
> +Users of HttpCore 4.2 are advised to upgrade.
>
>  Changelog
>  -------------------
>
> +* [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>
>
> Modified: 
> httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
> URL: 
> http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java?rev=1386795&r1=1386794&r2=1386795&view=diff
> ==============================================================================
> --- 
> httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
>  (original)
> +++ 
> httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
>  Mon Sep 17 19:58:17 2012
> @@ -76,12 +76,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);
> @@ -107,13 +107,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);
>          }
>
>

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

Reply via email to