-
Bug
-
Resolution: Done
-
Major
-
2.3.6.Final
-
None
-
None
-
I had a weird spurious problem with both sides of a web service transaction occasionally crashing with exceptions, using a RESTEasy client (v. 2.3.6) with a method that returns an InputStream.
I traced it down to the org.jboss.resteasy.client.core.BaseClientResponse ending up finalized while the client code is still reading data from the InputStream and the server still producing it. The client response object is the anonymous inner class instance created at ApacheHttpClient4Executor.execute(), which closes the stream at the performReleaseConection() method.
Solution: The returned InputStream instance should hold a reference to the response object to prevent it from being collected before the stream is done with. The easiest way is to make the stream itself an anonymous inner class of the client response at the getInputStream() method (ApacheHttpClient4Executor.java, line 194).
I had a weird spurious problem with both sides of a web service transaction occasionally crashing with exceptions, using a RESTEasy client (v. 2.3.6) with a method that returns an InputStream. I traced it down to the org.jboss.resteasy.client.core.BaseClientResponse ending up finalized while the client code is still reading data from the InputStream and the server still producing it. The client response object is the anonymous inner class instance created at ApacheHttpClient4Executor.execute(), which closes the stream at the performReleaseConection() method. Solution: The returned InputStream instance should hold a reference to the response object to prevent it from being collected before the stream is done with. The easiest way is to make the stream itself an anonymous inner class of the client response at the getInputStream() method (ApacheHttpClient4Executor.java, line 194).
- clones
-
RESTEASY-889 InputStream is closed because of finalize
-
- Closed
-