[ 
https://issues.apache.org/jira/browse/HTTPCORE-513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16362399#comment-16362399
 ] 

ASF GitHub Bot commented on HTTPCORE-513:
-----------------------------------------

GitHub user imoldovan-intacct reopened a pull request:

    https://github.com/apache/httpcomponents-core/pull/58

    ExpandableBuffer breaks on large response

    Ticket: https://issues.apache.org/jira/browse/HTTPCORE-513

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/imoldovan-intacct/httpcomponents-core master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/httpcomponents-core/pull/58.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #58
    
----
commit 0f16a5b320d46831231ae4e52a77a3e479b9db1d
Author: imoldovan-intacct <imoldovan@...>
Date:   2018-02-12T15:02:06Z

    ExpandableBuffer breaks on large response
    
    Ticket: https://issues.apache.org/jira/browse/HTTPCORE-513

commit 021bb0ee2ed5f3252e3bb0ce153e52369cefaead
Author: imoldovan-intacct <imoldovan@...>
Date:   2018-02-13T13:51:08Z

    ExpandableBuffer breaks on large response
    
    Ticket: https://issues.apache.org/jira/browse/HTTPCORE-513
    This closes #58

----


> ExpandableBuffer breaks on large response
> -----------------------------------------
>
>                 Key: HTTPCORE-513
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-513
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore, HttpCore NIO
>    Affects Versions: 4.4.9
>            Reporter: Ion Moldovan
>            Priority: Critical
>             Fix For: 5.0
>
>
> Steps:
>  # create a PHP page with the following content: 
>  ## <?php
>  $response='abc';
>  echo str_pad($response, 2147483647);
>  # send a request using jMeter to the said page
> Expected result: the request is received
> Actual result: the VM fails with:
> java.lang.OutOfMemoryError: Requested array size exceeds VM limit
>  Dumping heap to java_pid20344.hprof ...
>  Heap dump file created [3275879706 bytes in 7.490 secs]
>  Uncaught Exception java.lang.OutOfMemoryError: Requested array size exceeds 
> VM limit. See log file for details.
>  
> Proposed solution:
>  * rewrite org.apache.http.nio.util.ExpandableBuffer.expand() to:
>  
> {code:java}
> /**
> * Expands buffer's capacity.
> */
> protected void expand() {
>   int newcapacity = (this.buffer.capacity() + 1) << 1;
>   if (newcapacity < 0) {
>     int headRoom = Integer.max(Long.BYTES, 8);
>     // Reason: In GC the size of objects is passed as int (2 bytes). 
>     // Then, the header size of the objects is added to the size. 
>     // Long has the longest header available. Object header seems to be 
> linked to it. 
>     // Details: I added a minimum of 8 just to be safe and because 8 is used 
> in 
>     // java.lang.Object.ArrayList: private static final int MAX_ARRAY_SIZE = 
> 2147483639.
>     newcapacity = Integer.MAX_VALUE - headRoom; 
>   } 
>   expandCapacity(newcapacity); 
> }{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to