[ 
https://issues.apache.org/jira/browse/CXF-8950?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]
Sebastian Violet updated CXF-8950:
----------------------------------
    Description: 
When processing requests using the JAX RS client which used the new HttpClient, 
there is the input stream is closed prematurely.

 

[In the attached example|^], you will see that we are using {*}Response{*}, 
because we are interested in getting response status as well as the response 
headers. This fails with the following error:
{code:java}
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: 
closed
    at LargeDataTester.main(LargeDataTester.java:89)
Caused by: java.io.IOException: closed
    at 
java.net.http/jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.current(ResponseSubscribers.java:448)
    at 
java.net.http/jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.read(ResponseSubscribers.java:508)
    at java.base/java.io.FilterInputStream.read(FilterInputStream.java:119)
    at 
org.apache.cxf.transport.http.HttpClientHTTPConduit$HttpClientFilteredInputStream.read(HttpClientHTTPConduit.java:422)
    at java.base/java.io.SequenceInputStream.read(SequenceInputStream.java:197)
    at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:333)
    at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:376)
    at java.base/sun.nio.cs.StreamDecoder.lockedRead(StreamDecoder.java:219)
    at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:173)
    at java.base/java.io.InputStreamReader.read(InputStreamReader.java:189)
    at java.base/java.io.Reader.read(Reader.java:265)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1610)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1589)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:1384)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:1153)
    at org.apache.commons.io.IOUtils.toString(IOUtils.java:3105)
    at LargeDataTester.main(LargeDataTester.java:84)
Caused by: java.io.IOException: selector manager closed
    at 
java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.selectorClosedException(HttpClientImpl.java:1061)
    at 
java.net.http/jdk.internal.net.http.HttpClientImpl.closeSubscribers(HttpClientImpl.java:552)
    at 
java.net.http/jdk.internal.net.http.HttpClientImpl.stop(HttpClientImpl.java:543)
    at 
java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.shutdown(HttpClientImpl.java:1165)
    at 
java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:1364)
 {code}
 

 

You can execute the code like so:
{code:java}
mvn compile exec:exec{code}

  was:
When processing requests using the JAX RS client which used the new HttpClient, 
there is a memory leak.

We found this when running it in spring boot using
{code:java}
@Async{code}
 

I have tried to reproduce it using the attached code, and it seems to work with 
a low heap size.

 

You can execute the code like so:
{code:java}
mvn compile exec:exec{code}


> HttpClient in CXF closing prematurely; 4.0.4-SNAPSHOT
> -----------------------------------------------------
>
>                 Key: CXF-8950
>                 URL: https://issues.apache.org/jira/browse/CXF-8950
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 4.0.3
>            Reporter: Sebastian Violet
>            Assignee: Daniel Kulp
>            Priority: Major
>             Fix For: 3.6.3, 4.0.4
>
>         Attachments: CXF-HTTPClient-LargePayload.zip
>
>
> When processing requests using the JAX RS client which used the new 
> HttpClient, there is the input stream is closed prematurely.
>  
> [In the attached example|^], you will see that we are using {*}Response{*}, 
> because we are interested in getting response status as well as the response 
> headers. This fails with the following error:
> {code:java}
> Exception in thread "main" java.lang.RuntimeException: java.io.IOException: 
> closed
>     at LargeDataTester.main(LargeDataTester.java:89)
> Caused by: java.io.IOException: closed
>     at 
> java.net.http/jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.current(ResponseSubscribers.java:448)
>     at 
> java.net.http/jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.read(ResponseSubscribers.java:508)
>     at java.base/java.io.FilterInputStream.read(FilterInputStream.java:119)
>     at 
> org.apache.cxf.transport.http.HttpClientHTTPConduit$HttpClientFilteredInputStream.read(HttpClientHTTPConduit.java:422)
>     at 
> java.base/java.io.SequenceInputStream.read(SequenceInputStream.java:197)
>     at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:333)
>     at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:376)
>     at java.base/sun.nio.cs.StreamDecoder.lockedRead(StreamDecoder.java:219)
>     at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:173)
>     at java.base/java.io.InputStreamReader.read(InputStreamReader.java:189)
>     at java.base/java.io.Reader.read(Reader.java:265)
>     at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1610)
>     at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1589)
>     at org.apache.commons.io.IOUtils.copy(IOUtils.java:1384)
>     at org.apache.commons.io.IOUtils.copy(IOUtils.java:1153)
>     at org.apache.commons.io.IOUtils.toString(IOUtils.java:3105)
>     at LargeDataTester.main(LargeDataTester.java:84)
> Caused by: java.io.IOException: selector manager closed
>     at 
> java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.selectorClosedException(HttpClientImpl.java:1061)
>     at 
> java.net.http/jdk.internal.net.http.HttpClientImpl.closeSubscribers(HttpClientImpl.java:552)
>     at 
> java.net.http/jdk.internal.net.http.HttpClientImpl.stop(HttpClientImpl.java:543)
>     at 
> java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.shutdown(HttpClientImpl.java:1165)
>     at 
> java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:1364)
>  {code}
>  
>  
> You can execute the code like so:
> {code:java}
> mvn compile exec:exec{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to