You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2024/10/13 10:23:12 UTC

(httpcomponents-core) branch master updated: HTTPCORE-771: Ignore java.lang.UnsupportedOperationException when gracefully shutting classic SSL sockets for compatibility with Oracle JDK 1.8

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git


The following commit(s) were added to refs/heads/master by this push:
     new bf5871c83 HTTPCORE-771: Ignore java.lang.UnsupportedOperationException when gracefully shutting classic SSL sockets for compatibility with Oracle JDK 1.8
bf5871c83 is described below

commit bf5871c837e27e413ee7c480230f6c1ff7af03a4
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sat Oct 12 16:25:11 2024 +0200

    HTTPCORE-771: Ignore java.lang.UnsupportedOperationException when gracefully shutting classic SSL sockets for compatibility with Oracle JDK 1.8
---
 .../hc/core5/http/impl/io/BHttpConnectionBase.java       | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
index 8e88f22d9..df7c00bfd 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
@@ -248,11 +248,17 @@ class BHttpConnectionBase implements BHttpConnection {
                 try {
                     if (sslSocket != null) {
                         try {
-                            if (!sslSocket.isOutputShutdown()) {
-                                sslSocket.shutdownOutput();
-                            }
-                            if (!sslSocket.isInputShutdown()) {
-                                sslSocket.shutdownInput();
+                            try {
+                                if (!sslSocket.isOutputShutdown()) {
+                                    sslSocket.shutdownOutput();
+                                }
+                                if (!sslSocket.isInputShutdown()) {
+                                    sslSocket.shutdownInput();
+                                }
+                            } catch (final UnsupportedOperationException ignore) {
+                                // Some JREs such as Oracle JDK 1.8 do not support
+                                // Socket#shutdownOutput() and Socket#shutdownInput() methods
+                                // "because of the TLS half-close policy"
                             }
                             sslSocket.close();
                         } catch (final IOException ignore) {