Hi,
 
In the effort of upgrading axis2 to use httpclient 4.0 (was previously using 
commons-httpclient 3.1), i am running a junit that starts an Axis2 HTTP server 
(built on top of httpcore 4.0) and an Axis2 client using httpclient 4.0beta2 
(DefaultHttpClient class) as it's transport.
 
A request is successfully sent to the server, the DefaultHttpClient 
successfully handles the response and calls consumeContent() on the 
BasicHttpEntity, the problem is I get IOException because the Axis2 client 
stack tries to consume the InputStream again from BasicHttpEntity further down 
the execution path. 

I understand BasicHttpEntity is non-repeatable. That junit was working fine 
with httpclient 3.1, it was using httpMethod.getResponseBodyAsStream() which 
also cannot be repeated, from what I understand the 3.1 HttpClient would not 
automatically consume the response like the 4.0 version does.

Is using a ResponseHandler the reason why the HttpEntity response is consumed 
eagerly in DefaultHttpClient?
 
See I/O exception i'm currently getting:

java.io.IOException: Attempted read from closed stream.
 at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:145)
 at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:175)
 at 
org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:178)
 at com.sun.xml.fastinfoset.Decoder.peek(Decoder.java:1817)
 at com.sun.xml.fastinfoset.Decoder._isFastInfosetDocument(Decoder.java:1869)
 at com.sun.xml.fastinfoset.Decoder.decodeHeader(Decoder.java:1262)
 at 
com.sun.xml.fastinfoset.stax.StAXDocumentParser.next(StAXDocumentParser.java:220)
 at 
org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:506)
 at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:161)
 at 
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:156)
 at 
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:105)
 at 
org.apache.axis2.fastinfoset.FastInfosetBuilder.processDocument(FastInfosetBuilder.java:57)
 at 
org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:164)
 at 
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:112)
 at 
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:88)
 at 
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:353)
 at 
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
 at 
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
 at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
 at 
org.apache.axis2.fastinfoset.SimpleAddServiceStub.addStrings(SimpleAddServiceStub.java:740)
 at 
org.apache.axis2.fastinfoset.SimpleAddServiceClient.addStrings(SimpleAddServiceClient.java:104)
 at 
org.apache.axis2.fastinfoset.FastInfosetTest.testAdd(FastInfosetTest.java:49)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at junit.framework.TestCase.runTest(TestCase.java:168)
 at junit.framework.TestCase.runBare(TestCase.java:134)
 at junit.framework.TestResult$1.protect(TestResult.java:110)
 at junit.framework.TestResult.runProtected(TestResult.java:128)
 at junit.framework.TestResult.run(TestResult.java:113)
 at junit.framework.TestCase.run(TestCase.java:124)
 at junit.framework.TestSuite.runTest(TestSuite.java:232)
 at junit.framework.TestSuite.run(TestSuite.java:227)
 at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
 at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
 at junit.framework.TestResult.runProtected(TestResult.java:128)
 at junit.extensions.TestSetup.run(TestSetup.java:27)
 at 
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
 at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
 at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Apr 21, 2009 3:43:11 PM org.apache.axis2.deployment.DeploymentEngine 
prepareRepository
 
Please advise,
Thanks,
-Guillaume


____________________________________________________________________________________________________
This electronic mail (including any attachments) may contain information that 
is privileged, confidential, and/or otherwise protected from disclosure to 
anyone other than its intended recipient(s). Any dissemination or use of this 
electronic email or its contents (including any attachments) by persons other 
than the intended recipient(s) is strictly prohibited. If you have received 
this message in error, please notify us immediately by reply email so that we 
may correct our internal records. Please then delete the original message 
(including any attachments) in its entirety. Thank you.

Reply via email to