美文网首页
报错Attempted read from closed str

报错Attempted read from closed str

作者: coder_farmer | 来源:发表于2017-12-08 10:34 被阅读0次

    下面是报错内容:

        java.io.IOException: Attempted read from closed stream.  
            at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:167)  
            at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)  
            at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)  
            at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)  
            at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)  
            at java.io.InputStreamReader.read(InputStreamReader.java:167)  
            at java.io.Reader.read(Reader.java:123)  
            at org.apache.http.util.EntityUtils.toString(EntityUtils.java:244)  
            at org.apache.http.util.EntityUtils.toString(EntityUtils.java:288)  
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)  
            ...... ......  
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)  
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)  
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)  
            at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)  
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)  
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)  
            at com.baitian.pay.filter.BehaviorLogFilter.doFilter(Unknown Source)  
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)  
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)  
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)  
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)  
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)  
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)  
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)  
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)  
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)  
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)  
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)  
            at java.lang.Thread.run(Thread.java:619)  
    

    原来在发送请求以后收到response后,使用EntityUtils.toString(HttpEntity )时候,流就已经关闭了,所以这个方法只能调用一次。否则就报在关闭的流中读取数据。

    相关文章

      网友评论

          本文标题:报错Attempted read from closed str

          本文链接:https://www.haomeiwen.com/subject/zozsixtx.html