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/17 21:58:17 UTC
svn commit: r1386795 - in /httpcomponents/httpcore/branches/4.2.x:
RELEASE_NOTES.txt
httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
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
+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);
}
Re: svn commit: r1386795
Posted by sebb <se...@gmail.com>.
On 17 September 2012 22:39, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Mon, 2012-09-17 at 22:29 +0100, sebb wrote:
>> On 17 September 2012 21:45, Oleg Kalnichevski <ol...@apache.org> wrote:
>> > On Mon, 2012-09-17 at 21:28 +0100, sebb wrote:
>> >> On 17 September 2012 20:58, <ol...@apache.org> 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/
>> >>
>> >
>> > My bad. My English has its limits, especially if I forget to proofread.
>>
>> It's a lot easier proofreading someone else's prose ...
>>
>> > Just fix and commit. I'll never complain ;-)
>>
>> Sorry, that's me being lazy. I don't have a workspace for the files at
>> the moment.
>>
>
> That makes two of us ;-) Fixes committed. Please double-check.
Looks fine now, thanks.
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: svn commit: r1386795
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2012-09-17 at 22:29 +0100, sebb wrote:
> On 17 September 2012 21:45, Oleg Kalnichevski <ol...@apache.org> wrote:
> > On Mon, 2012-09-17 at 21:28 +0100, sebb wrote:
> >> On 17 September 2012 20:58, <ol...@apache.org> 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/
> >>
> >
> > My bad. My English has its limits, especially if I forget to proofread.
>
> It's a lot easier proofreading someone else's prose ...
>
> > Just fix and commit. I'll never complain ;-)
>
> Sorry, that's me being lazy. I don't have a workspace for the files at
> the moment.
>
That makes two of us ;-) Fixes committed. Please double-check.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: svn commit: r1386795
Posted by sebb <se...@gmail.com>.
On 17 September 2012 21:45, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Mon, 2012-09-17 at 21:28 +0100, sebb wrote:
>> On 17 September 2012 20:58, <ol...@apache.org> 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/
>>
>
> My bad. My English has its limits, especially if I forget to proofread.
It's a lot easier proofreading someone else's prose ...
> Just fix and commit. I'll never complain ;-)
Sorry, that's me being lazy. I don't have a workspace for the files at
the moment.
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: svn commit: r1386795
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2012-09-17 at 21:28 +0100, sebb wrote:
> On 17 September 2012 20:58, <ol...@apache.org> 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/
>
My bad. My English has its limits, especially if I forget to proofread.
Just fix and commit. I'll never complain ;-)
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: svn commit: r1386795 - in /httpcomponents/httpcore/branches/4.2.x:
RELEASE_NOTES.txt httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
Posted by sebb <se...@gmail.com>.
On 17 September 2012 20:58, <ol...@apache.org> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org