Running the following code snippet:
URL url = new URL(uri);
URLConnection urlconn = url.openConnection();
urlconn.connect();
urlconn.getContentLength();
I get the dead-lock sometimes, usually at two lines: urlconn.connect()
and urlconn.getContentLength()
. Also, when I do
InputStream is = urlconn.getInputStream();
// doing some reading
is.close();
I also get blocking at is.close()
. I want to ask why such blocking happens. It is clueless to me from the Java API.