HttpURLConnection becomes blocked

I have a thread running under tomcat that creates an HttpUrlConnection and reads it through a BufferedInputStream.

After retrieving data for some URLs, it stops. I got a jstack of a process which says that the HttpUrlConnection is locked and the BufferedInputStream is also locked.

"http-8080-1" daemon prio=10 tid=0x08683400 nid=0x79c9 runnable [0x8f618000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) - locked <0x956ef8c0> (a java.io.BufferedInputStream) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1072) - locked <0x956ef910> (a sun.net.www.protocol.http.HttpURLConnection) 

Did anyone here help. Thanks

+6
java locking
source share
1 answer

You probably have a problem on the other end. read () in InputStream - blocking operation - from javadoc ( http://java.sun.com/javase/6/docs/api/ ): "This method is blocked until the input data is available, the end of the stream is detected or an exception is thrown. "

Will the server respond at the other end? Do you know that it is sent?

edit: To make it clearer, the thread is in RUNNABLE state, so you are not at a dead end - it looks like you think it is, but there is no evidence of any dead end.

+6
source

All Articles