I’m creating a class for making the download of an item. I’m using the following method for connect and retrieve the download info:
public mDownload(String url) throws MalformedURLException {
this.url = new URL(url);
}
private void connect() throws IOException {
connection = url.openConnection();
date = connection.getDate();
--> expiration = connection.getExpiration();
length = connection.getContentLength();
lastModified = connection.getLastModified();
}
But I have some reports of force crashes at the --> line:
java.lang.IllegalStateException: getInputStream() is not available. Is this a reentrant call?
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:524)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:464)
at java.net.URLConnection.getHeaderFieldDate(URLConnection.java:548)
at java.net.HttpURLConnection.getHeaderFieldDate(HttpURLConnection.java:702)
at java.net.URLConnection.getExpiration(URLConnection.java:426)
Why is this error happening and how can I avoid it? Thanks!
Looking at this commit, this may be a poor exception message. It may be that the response failed to return any data. You could confirm by monitoring the actual network traffic.