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 2019/09/05 14:53:09 UTC

[httpcomponents-core] 01/01: HTTPCORE-595: tolerate NPE thrown by com.android.org.conscrypt.NativeCrypto#SSL_get_shutdown in Android Conscript

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

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

commit 547655dfcb618da138cdaffe337a7126715dc4a2
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Thu Sep 5 16:52:34 2019 +0200

    HTTPCORE-595: tolerate NPE thrown by com.android.org.conscrypt.NativeCrypto#SSL_get_shutdown in Android Conscript
---
 .../main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
index e302bbc..708978b 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
@@ -683,9 +683,15 @@ public class SSLIOSession implements IOSession {
                     this.session.setSocketTimeout(Timeout.ofMilliseconds(1000));
                 }
                 try {
+                    // Catch all unchecked exceptions in case something goes wrong
+                    // in the JSSE provider. For instance
+                    // com.android.org.conscrypt.NativeCrypto#SSL_get_shutdown can
+                    // throw NPE at this point
                     updateEventMask();
                 } catch (final CancelledKeyException ex) {
-                    close(CloseMode.GRACEFUL);
+                    this.session.close(CloseMode.GRACEFUL);
+                } catch (final Exception ex) {
+                    this.session.close(CloseMode.IMMEDIATE);
                 }
             } else {
                 if (this.status == CLOSED) {