javax.net.ssl.SSLException:在使用Java 11接收对等方的close_notify之前关闭入站

问题描述

在java 11的http响应上调用close时,我收到以下异常。这曾经与Java 8一起使用。

Caused by: javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:133)
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:313)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:269)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:260)
    at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:737)
    at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:716)
    at org.apache.http.impl.BHttpConnectionBase.close(BHttpConnectionBase.java:327)
    at org.apache.http.impl.conn.LoggingManagedHttpClientConnection.close(LoggingManagedHttpClientConnection.java:81)
    at org.apache.http.impl.conn.CPoolEntry.closeConnection(CPoolEntry.java:70)
    at org.apache.http.impl.conn.CPoolProxy.close(CPoolProxy.java:86)
    at org.apache.http.impl.execchain.ConnectionHolder.releaseConnection(ConnectionHolder.java:103)
    at org.apache.http.impl.execchain.ConnectionHolder.close(ConnectionHolder.java:156)
    at org.apache.http.impl.execchain.HttpResponseProxy.close(HttpResponseProxy.java:62)

上面的异常发生在以下代码中调用response.close()时:

    HttpGet httpRequest = new HttpGet(url);
    CloseableHttpResponse response = null;
    BufferedReader reader = null;
    try {
        response = httpClient.execute(httpRequest);
        reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        String line = "";
        while((line = reader.readLine()) != null) {
         // do something with the line
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    } finally {
        if (response != null) {
            response.close();
        }
        if (reader != null) {
            reader.close();
        }
    }

我正在使用httpclient 4.5.3。 我在reader.close()上也观察到相同的错误。

感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)