从apache HttpClient读取关闭流错误

时间:2012-03-04 11:20:08

标签: java httpclient inputstream apache-commons-httpclient apache-abdera

我正在尝试解析来自Apache HttpClient(3.1)响应的响应,如下所示:

try {  
    int code = mclient.executeMethod(method);
    if (code == Status.OK.getCode()) {
        st = method.getResponseBodyAsStream();
        XMLBean el = doSomething(st);
        return el;
    }
} catch (HttpException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
} finally {
    method.releaseConnection();
}

在使用atom解析器解析响应时,这给了我以下异常。

org.apache.abdera.parser.ParseException: java.lang.RuntimeException: [was class java.io.IOException] Attempted read on closed stream.

finally块实际上关闭了连接。什么可能导致这个封闭的流错误?

SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
org.apache.abdera.parser.ParseException: java.lang.RuntimeException: [was class java.io.IOException] Attempted read on closed stream.
    at org.apache.abdera.parser.stax.FOMBuilder.next(FOMBuilder.java:244)
    at org.apache.axiom.om.impl.llom.OMElementImpl.getNextOMSibling(OMElementImpl.java:337)
    at org.apache.axiom.om.impl.traverse.OMChildrenQNameIterator.next(OMChildrenQNameIterator.java:118)
    at org.apache.axiom.om.impl.llom.OMElementImpl.getFirstChildWithName(OMElementImpl.java:275)
    at org.apache.abdera.parser.stax.FOMElement.getFirstChild(FOMElement.java:180)

0 个答案:

没有答案