From 533dcfb828e4331a8ca6e81b152c9613e2de0768 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Fri, 23 Sep 2022 10:37:32 -0400 Subject: [PATCH] Improve handling of SSLExceptions. Current theory is that some Samsung devices a doing something funky with SSLExceptions, causing them to not be caught as IOExceptions. --- .../util/SignalUncaughtExceptionHandler.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/SignalUncaughtExceptionHandler.java b/app/src/main/java/org/thoughtcrime/securesms/util/SignalUncaughtExceptionHandler.java index c38819e280..986b6ab2cf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/SignalUncaughtExceptionHandler.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/SignalUncaughtExceptionHandler.java @@ -7,6 +7,10 @@ import org.signal.core.util.logging.Log; import org.thoughtcrime.securesms.dependencies.ApplicationDependencies; import org.thoughtcrime.securesms.keyvalue.SignalStore; +import java.io.IOException; + +import javax.net.ssl.SSLException; + import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException; public class SignalUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { @@ -21,6 +25,16 @@ public class SignalUncaughtExceptionHandler implements Thread.UncaughtExceptionH @Override public void uncaughtException(@NonNull Thread t, @NonNull Throwable e) { + // Seeing weird situations where SSLExceptions aren't being caught as IOExceptions + if (e instanceof SSLException) { + if (e instanceof IOException) { + Log.w(TAG, "Uncaught SSLException! It *is* an IOException!", e); + } else { + Log.w(TAG, "Uncaught SSLException! It is *not* an IOException!", e); + } + return; + } + if (e instanceof OnErrorNotImplementedException && e.getCause() != null) { e = e.getCause(); }