[
https://issues.apache.org/jira/browse/AXIOM-524?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Michael Suhr updated AXIOM-524:
-------------------------------
Affects Version/s: 1.4.0
> Attempted read on closed stream for multithreaded environment
> -------------------------------------------------------------
>
> Key: AXIOM-524
> URL: https://issues.apache.org/jira/browse/AXIOM-524
> Project: Axiom
> Issue Type: Bug
> Affects Versions: 1.4.0, 2.0.0
> Reporter: Michael Suhr
> Priority: Minor
>
> I don't know if it's an issue for Axiom, Axis or the underlying Http Client
> (Httpclient 5 in my case).
> I have a wsdl Service and call them often. Sometimes an error is shown:
> {noformat}
> org.apache.axiom.om.OMException: java.io.IOException: Attempted read on
> closed stream.
> at
> org.apache.axiom.om.impl.common.factory.meta.DetachableInputStream.detach(DetachableInputStream.java:75)
> at
> org.apache.axiom.om.impl.common.builder.OMXMLParserWrapperImpl.detach(OMXMLParserWrapperImpl.java:92)
> at
> org.apache.axis2.kernel.TransportUtils.detachInputStream(TransportUtils.java:578)
> ...
> Caused by: java.io.IOException: Attempted read on closed stream.
> at
> org.apache.hc.core5.http.io.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:107)
> at
> org.apache.hc.core5.http.io.EofSensorInputStream.read(EofSensorInputStream.java:133)
> at
> org.apache.axiom.blob.MemoryBlobOutputStreamImpl.readFrom(MemoryBlobOutputStreamImpl.java:83)
> at org.apache.axiom.blob.MemoryBlobImpl.readFrom(MemoryBlobImpl.java:67)
> at
> org.apache.axiom.om.impl.common.factory.meta.DetachableInputStream.detach(DetachableInputStream.java:73)
> {noformat}
> For some investigation I added some breakpoints in IntelliJ to force a sleep.
> h5. Debugging hints
> - Add breakpoint with Evaluate at:
> {code:java|title=org.apache.axiom.om.impl.common.factory.meta.DetachableInputStream#detach}
> // Some comments here
> @Override
> public void detach() throws OMException {
> MemoryBlob blob = Blobs.createMemoryBlob(); //<-- add log here to see
> when its called
> try {
> blob.readFrom(target); <-- add here breakpoint (no suspend) with
> Thread.sleep(2000) and log that it shoul read
> } catch (StreamCopyException ex) {
> throw new OMException(ex.getCause()); <-- Here Breapoint to stop
> on error
> }
> if (closeOnDetach) {
> try {
> target.close();
> } catch (IOException ex) {
> throw new OMException(ex);
> }
> }
> target = blob.readOnce();
> }
> {code}
> - add beakpoint with log {{"close " + Thread.currentThread().getName() + " -
> " + this.toString()}}:
> {code:java|title=org.apache.hc.core5.http.io.EofSensorInputStream#close}
> // Some comments here
> public void close() throws IOException {
> // tolerate multiple calls to close()
> selfClosed = true; // <-- add here the Log
> checkClose();
> }
> {code}
> If the service is now called twice I got the following log:
> {noformat}
> close http-nio-8280-exec-8 -
> org.apache.hc.core5.http.io.EofSensorInputStream@415a5c70
> isReadAllowed: http-nio-8280-exec-8 -
> org.apache.hc.core5.http.io.EofSensorInputStream@757826d0: true
> detach http-nio-8280-exec-8 -
> org.apache.hc.core5.http.io.EofSensorInputStream@757826d0
> Breakpoint reached at
> org.apache.hc.core5.http.io.EofSensorInputStream.close(EofSensorInputStream.java:174)
> close http-nio-8280-exec-6 -
> org.apache.hc.core5.http.io.EofSensorInputStream@757826d0
> isReadAllowed: http-nio-8280-exec-6 -
> org.apache.hc.core5.http.io.EofSensorInputStream@48d7382c: true
> detach http-nio-8280-exec-6 -
> org.apache.hc.core5.http.io.EofSensorInputStream@48d7382c
> detach after sleep: http-nio-8280-exec-8 -
> org.apache.hc.core5.http.io.EofSensorInputStream@757826d0
> isReadAllowed: http-nio-8280-exec-8 -
> org.apache.hc.core5.http.io.EofSensorInputStream@757826d0: false
> detach after sleep: http-nio-8280-exec-6 -
> org.apache.hc.core5.http.io.EofSensorInputStream@48d7382c
> isReadAllowed: http-nio-8280-exec-6 -
> org.apache.hc.core5.http.io.EofSensorInputStream@48d7382c: true
> Breakpoint reached at
> org.apache.hc.core5.http.io.EofSensorInputStream.close(EofSensorInputStream.java:174)
> close http-nio-8280-exec-6 -
> org.apache.hc.core5.http.io.EofSensorInputStream@48d7382c
> Breakpoint reached at
> org.apache.axiom.om.impl.common.factory.meta.DetachableInputStream.detach(DetachableInputStream.java:75)
> detach after sleep: http-nio-8280-exec-8 -
> org.apache.hc.core5.http.io.EofSensorInputStream@757826d0
> Breakpoint reached at
> org.apache.hc.core5.http.io.EofSensorInputStream.close(EofSensorInputStream.java:174)
> close http-nio-8280-exec-8 -
> org.apache.hc.core5.http.io.EofSensorInputStream@757826d0
> {noformat}
> You see that for {{EofSensorInputStream@757826d0}} the thread
> {{http-nio-8280-exec-8}} enter the detach method. but in meantime the thread
> {{http-nio-8280-exec-6 }} call close on it.
> I try to create a running Test for it and if possible I will provide it to
> you as well
> Maybe related to: AXIOM-517
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]