hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1425) Socket Closed Exception When Reading Connection: close Response Entities
Date Fri, 18 Oct 2013 20:41:43 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13799494#comment-13799494
] 

Oleg Kalnichevski commented on HTTPCLIENT-1425:
-----------------------------------------------

James, unless you help us narrow down the problem somewhat or at least provide more contextual
details we are unlikely to be able to resolve the issue. Wire / context logs of both sessions
(caching and non-caching) would probably be already quite helpful.

Oleg 

> Socket Closed Exception When Reading Connection: close Response Entities
> ------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1425
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1425
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCache
>    Affects Versions: 4.3.1
>         Environment: java version "1.7.0_25"
> OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4ubuntu3)
> OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
>            Reporter: James Leigh
>             Fix For: 4.3.2
>
>
> If the server closes the TCP connection, immediately after sending the complete response,
httpclient-cache will throw socket closed exception.
> The server at http://3roundstones.com/ will close the response immediately after sending
the complete response and will include the headers: Connection: close and Transfer-Encoding:
chunked.
> HttpClient can deal with this response no problem (using HttpClients.createDefault).
However, CachingHttpClients.createMemoryBound throws an exception every time I try it. Below
is some code (mostly taken of the docs) that also fails every time. Further down is the stack
trace it produces.
> CacheConfig cacheConfig = CacheConfig.custom().build();
> RequestConfig requestConfig = RequestConfig.custom().build();
> CloseableHttpClient httpclient = CachingHttpClients.custom()
> 		.setCacheConfig(cacheConfig)
> 		.setDefaultRequestConfig(requestConfig).build();
> HttpCacheContext context = HttpCacheContext.create();
> HttpGet httpget = new HttpGet("http://3roundstones.com/");
> CloseableHttpResponse response = httpclient.execute(httpget, context);
> try {
> 	String body = EntityUtils.toString(response.getEntity());
> 	assertTrue(body.length() > 0);
> } finally {
> 	response.close();
> 	httpclient.close();
> }
> java.net.SocketException: Socket closed
> 	at java.net.SocketInputStream.socketRead0(Native Method)
> 	at java.net.SocketInputStream.read(SocketInputStream.java:150)
> 	at java.net.SocketInputStream.read(SocketInputStream.java:121)
> 	at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:136)
> 	at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:152)
> 	at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:270)
> 	at org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:240)
> 	at org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:206)
> 	at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:169)
> 	at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)
> 	at java.io.SequenceInputStream.read(SequenceInputStream.java:208)
> 	at java.io.SequenceInputStream.read(SequenceInputStream.java:211)
> 	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
> 	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
> 	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
> 	at java.io.InputStreamReader.read(InputStreamReader.java:184)
> 	at java.io.Reader.read(Reader.java:140)
> 	at org.apache.http.util.EntityUtils.toString(EntityUtils.java:244)
> 	at org.apache.http.util.EntityUtils.toString(EntityUtils.java:288)



--
This message was sent by Atlassian JIRA
(v6.1#6144)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message