commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13010] New: - [PATCH] java.net.SocketException when validating
Date Wed, 25 Sep 2002 23:09:16 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13010>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13010

[PATCH] java.net.SocketException when validating

           Summary: [PATCH] java.net.SocketException when validating
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Latka
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: janekdb@yahoo.co.uk


Synopsis
--------

The CVS version of Latka throws a java.net.SocketException when using the CVS
version of HttpClient. The transfer encoding of the HTTP response is "chunked"
when this happens.

When the exception is thrown the underlying implementation of the response
stream is o.a.c.httpclient.ChunkedInputStream. This stream is asked to read from
the socket after the HttpConnection has been closed.

I have not determined if the "chunked" transfer encoding is required for the
exception to be thrown or not.

Solution
--------

My solution is to force the response body to be cached before the connection is
closed in o.a.c.latka.http.RequestImpl.execute(). It's inelegant but got the
unit test working. See attached patch.

Stack trace extract
-------------------

This is part of the stack trace resulting from '$ ant clean build test'

ERROR  o.a.c.httpclient.HttpMethodBase - getResponseBody failed
java.net.SocketException: Socket closed
	at java.net.SocketInputStream.socketRead(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:86)


Test suite
----------

This is my minimum test suite which gives the stack trace.

<suite defaultHost="fresher.home.com" label="xxx">

  <request path="/ok.html" label="RESULTS PAGE">
    <validate>
      <regexp pattern="office"/>
    </validate>
  </request>

</suite>


HTTP transaction
----------------

This is the complete http exchange that happened before the http connection was
closed in RequestImpl.

httpclient.wire - >> "GET /ok.html HTTP/1.1
httpclient.wire - >> "Host: fresher.home.com
httpclient.wire - >> "User-Agent: Jakarta Commons-HttpClient/2.0M1
httpclient.wire - >> [\r\n]
httpclient.wire - << "HTTP/1.1 200 OK" [\r\n]
httpclient.wire - << "Date: Wed, 25 Sep 2002 23:07:11 GMT" [\r\n]
httpclient.wire - << "Server: Apache/1.3.19 (Unix) mod_webapp/1.2.0-dev
PHP/4.0.4pl1" [\r\n]
httpclient.wire - << "Content-Type: text/html;charset=ISO-8859-1" [\r\n]
httpclient.wire - << "Set-Cookie:
JSESSIONID=0573C1C522273833C864546779D42663;Path=/" [\r\n]
httpclient.wire - << "Transfer-Encoding: chunked" [\r\n]
httpclient.wire - << 1
httpclient.wire - << 4
httpclient.wire - << 7
httpclient.wire - << 1
httpclient.wire - <<
httpclient.wire - <<

Stack trace tail
----------------

This is the long version of the stack trace.

INFO   o.a.c.latka.http.RequestImpl - response obtained (response logging
disabled because some responses are binary)
DEBUG  o.a.c.latka.http.RequestImpl - response: o.a.c.latka.http.ResponseImpl@ece65
DEBUG  o.a.c.latka.http.RequestImpl - About to invoke getResource ()
DEBUG  o.a.c.latka.http.ResponseImpl - getResource ():
o.a.c.latka.http.ResponseImpl@ece65
DEBUG  o.a.c.latka.http.ResponseImpl - getStatusCode (): 200
DEBUG  o.a.c.latka.http.ResponseImpl - getStatusText (): OK
DEBUG  o.a.c.latka.http.ResponseImpl - getHeader ( Server ): Apache/1.3.19
(Unix) mod_webapp/1.2.0-dev PHP/4.0.4pl1
DEBUG  o.a.c.latka.http.ResponseImpl - _httpMethod:
o.a.c.httpclient.methods.GetMethod
DEBUG  o.a.c.httpclient.methods.GetMethod - enter GetMethod.getResponseBody()
DEBUG  o.a.c.httpclient.HttpMethodBase - BEFORE: InputStream is =
getResponseBodyAsStream()
DEBUG  o.a.c.httpclient.methods.GetMethod - enter
GetMethod.getResponseBodyAsStream()
DEBUG  o.a.c.httpclient.HttpMethodBase - getResponseBodyAsStream: responseStream
= o.a.c.httpclient.ChunkedInputStream@69ca65
DEBUG  o.a.c.httpclient.HttpMethodBase - AFTER: InputStream is =
getResponseBodyAsStream()
DEBUG  o.a.c.httpclient.ChunkedInputStream - ChunkedInputStream.read (
byte[].length: 10000 )
DEBUG  o.a.c.httpclient.ChunkedInputStream - ChunkedInputStream.read (
byte[].length: 10000, off: 0, len: 10000 )
ERROR  o.a.c.httpclient.HttpMethodBase - getResponseBody failed
java.net.SocketException: Socket closed
	at java.net.SocketInputStream.socketRead(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:86)
	at java.io.FilterInputStream.read(FilterInputStream.java:114)
	at o.a.c.httpclient.WireLogInputStream.read(WireLogInputStream.java:85)
	at o.a.c.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:148)
	at o.a.c.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:155)
	at o.a.c.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:537)
	at o.a.c.httpclient.methods.GetMethod.getResponseBody(GetMethod.java:239)
	at o.a.c.latka.http.ResponseImpl.getByteLength(Unknown Source)
	at o.a.c.latka.http.ResponseImpl.getResource(Unknown Source)
	at o.a.c.latka.http.RequestImpl.execute(Unknown Source)
	at o.a.c.latka.xml.RequestHandler.executeRequest(Unknown Source)
	at o.a.c.latka.xml.RequestHandler.startElement(Unknown Source)
	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1475)
	at org.apache.crimson.parser.Parser2.content(Parser2.java:1766)
	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1494)
	at org.apache.crimson.parser.Parser2.content(Parser2.java:1766)
	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1494)
	at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
	at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
	at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
	at o.a.c.latka.Latka.runTests(Unknown Source)
	at o.a.c.latka.junit.JUnitTestAdapter.run(Unknown Source)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.textui.TestRunner.doRun(TestRunner.java:116)
	at junit.textui.TestRunner.start(TestRunner.java:172)
	at junit.textui.TestRunner.main(TestRunner.java:138)
DEBUG  o.a.c.latka.http.ResponseImpl - getByteLength (): -1
DEBUG  o.a.c.httpclient.methods.GetMethod - enter GetMethod.getResponseBody()
DEBUG  o.a.c.httpclient.HttpMethodBase - BEFORE: InputStream is =
getResponseBodyAsStream()
DEBUG  o.a.c.httpclient.methods.GetMethod - enter
GetMethod.getResponseBodyAsStream()
DEBUG  o.a.c.httpclient.HttpMethodBase - getResponseBodyAsStream: responseStream
= o.a.c.httpclient.ChunkedInputStream@69ca65
DEBUG  o.a.c.httpclient.HttpMethodBase - AFTER: InputStream is =
getResponseBodyAsStream()
DEBUG  o.a.c.httpclient.ChunkedInputStream - ChunkedInputStream.read (
byte[].length: 10000 )
DEBUG  o.a.c.httpclient.ChunkedInputStream - ChunkedInputStream.read (
byte[].length: 10000, off: 0, len: 10000 )
ERROR  o.a.c.httpclient.HttpMethodBase - getResponseBody failed
java.net.SocketException: Socket closed
	at java.net.SocketInputStream.socketRead(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:86)
	at java.io.FilterInputStream.read(FilterInputStream.java:114)
	at o.a.c.httpclient.WireLogInputStream.read(WireLogInputStream.java:85)
	at o.a.c.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:148)
	at o.a.c.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:155)
	at o.a.c.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:537)
	at o.a.c.httpclient.methods.GetMethod.getResponseBody(GetMethod.java:239)
	at o.a.c.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:584)
	at o.a.c.latka.http.ResponseImpl.getResource(Unknown Source)
	at o.a.c.latka.http.RequestImpl.execute(Unknown Source)
	at o.a.c.latka.xml.RequestHandler.executeRequest(Unknown Source)
	at o.a.c.latka.xml.RequestHandler.startElement(Unknown Source)
	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1475)
	at org.apache.crimson.parser.Parser2.content(Parser2.java:1766)
	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1494)
	at org.apache.crimson.parser.Parser2.content(Parser2.java:1766)
	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1494)
	at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
	at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
	at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
	at o.a.c.latka.Latka.runTests(Unknown Source)
	at o.a.c.latka.junit.JUnitTestAdapter.run(Unknown Source)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.textui.TestRunner.doRun(TestRunner.java:116)
	at junit.textui.TestRunner.start(TestRunner.java:172)
	at junit.textui.TestRunner.main(TestRunner.java:138)
ERROR  o.a.c.latka.junit.JUnitTestAdapter - Unable to execute latka tests
Wrapped Exception details:
java.lang.NullPointerException
	at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:524)
	at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
	at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
	at o.a.c.latka.Latka.runTests(Unknown Source)
	at o.a.c.latka.junit.JUnitTestAdapter.run(Unknown Source)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.textui.TestRunner.doRun(TestRunner.java:116)
	at junit.textui.TestRunner.start(TestRunner.java:172)
	at junit.textui.TestRunner.main(TestRunner.java:138)
o.a.c.latka.LatkaException: java.lang.NullPointerException
	at o.a.c.latka.Latka.runTests(Unknown Source)
	at o.a.c.latka.junit.JUnitTestAdapter.run(Unknown Source)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.textui.TestRunner.doRun(TestRunner.java:116)
	at junit.textui.TestRunner.start(TestRunner.java:172)
	at junit.textui.TestRunner.main(TestRunner.java:138)

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message