IllegalStateException:getInputStream()不可用。这是一个可重入的电话吗?

时间:2012-09-12 15:44:45

标签: java android http

我正在创建一个用于下载项目的类。我正在使用以下方法进行连接并检索下载信息:

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();
}

但我有一些关于-->行强制崩溃的报告:

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)

为什么会发生此错误,我该如何避免?谢谢!

1 个答案:

答案 0 :(得分:1)

查看this commit,这可能是一个糟糕的异常消息。可能是响应无法返回任何数据。您可以通过监控实际网络流量来确认。