[ https://issues.apache.org/jira/browse/CXF-8950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17779590#comment-17779590 ]
Daniel Kulp commented on CXF-8950: ---------------------------------- Discussing this with [~reta], we don't believe this is a valid bug. You are specifically closing the client (in the try with resources block) but then continuing to use objects (the Response) that are expecting the client to still be open/connected. You need to be fully done with the client prior to calling close (or don't call close and allow the garbage collector to clean it up, but that would not be deterministic as to when that would happen). Or re-use the clients (which would have other benefits with keep-alives, http/2, etc..). When closing the client, all resources associated with that client are no longer valid. You would definitely need to fully consume the entity prior to closing the client. > 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, 4.0.4 > Reporter: Sebastian Violet > Assignee: Daniel Kulp > Priority: Critical > 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. > > [^CXF-HTTPClient-LargePayload.zip] , 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} > > {color:#FF0000}*You can execute the code like so:*{color} > {code:java} > mvn compile exec:exec{code} > ℹ️ {*}Note{*}: You can do a diff between what works(Letting CXF deserialize > the object response payload automatically), and the last commit(Using > Response). > {code:java} > git diff HEAD^ HEAD {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)