Code Review Request: 8015421: NegativeArraySizeException occurs in ChunkedOutputStream() with Integer.MAX_VALUE
Kurchi Hazra
kurchi.subhra.hazra at oracle.com
Wed Jun 12 16:11:29 PDT 2013
Apologies, I had used the wrong subject line - correcting it here for
records.
On 6/12/2013 11:41 AM, Kurchi Hazra wrote:
> Right, what I have now should not be really problematic, it will throw
> an OutOfMemoryError and I pass the test in that case. But
> I am ok with skipping it too.
>
> I'll just push the source code change then.
>
> - Kurchi
>
> On 6/12/2013 11:37 AM, Chris Hegarty wrote:
>> On 12 Jun 2013, at 19:29, Chris Hegarty <chris.hegarty at oracle.com>
>> wrote:
>>
>>> The source change looks fine to me, since our implementation treats
>>> the given chunk length as the complete chunk size ( including header
>>> & footer ).
>>>
>>> I would prefer to not add a test, if the test will end up being
>>> problematic, given this is a corner case.
>> I mean, when running tests in the samevm concurrently.
>>
>> -Chris
>>
>>> -Chris
>>>
>>> On 12 Jun 2013, at 18:48, Kurchi Hazra
>>> <kurchi.subhra.hazra at oracle.com> wrote:
>>>
>>>>
>>>>
>>>> Hi,
>>>>
>>>> In HttpUrlConnection, if the chunk length is set to
>>>> Integer.MAX_VALUE, our code was trying to initialize a buffer of size
>>>> greater than that, which was resulting in an integer overflow, and
>>>> consequently a NegativeArraySizeException. This fix
>>>> ensures that while initializing the internal buffer, we never
>>>> exceed the maximum size of the chunk length fixed by the user,
>>>> and hence avert the NegativeArraySizeException.
>>>>
>>>> I have added a test to cover the case. The test will however try to
>>>> create a buffer of size Integer.MAX_VALUE. I could
>>>> change the value of the JVM heap, but the required size (~2 GB)
>>>> will be too large for most machines to support.
>>>> However, I am open to advice as to what I should do in this case.
>>>>
>>>> Bug: http://bugs.sun.com/view_bug.do?bug_id=8015421
>>>> Webrev: http://cr.openjdk.java.net/~khazra/8015421/webrev.00/
>>>>
>>>>
>>>>
>>>> Thanks,
>>>> Kurchi
>
--
-Kurchi
More information about the net-dev
mailing list