Skip to content

Commit

Permalink
Fix Conscrypt NPE workaround (square#7219)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilGlass committed Apr 9, 2022
1 parent 7cdc726 commit 6ba23dc
Showing 1 changed file with 6 additions and 7 deletions.
Expand Up @@ -79,16 +79,15 @@ open class AndroidSocketAdapter(private val sslSocketClass: Class<in SSLSocket>)
return try {
val alpnResult = getAlpnSelectedProtocol.invoke(sslSocket) as ByteArray?
alpnResult?.toString(Charsets.UTF_8)
} catch (e: NullPointerException) {
// https://github.com/square/okhttp/issues/5587
when (e.message) {
"ssl == null" -> null
else -> throw e
}
} catch (e: IllegalAccessException) {
throw AssertionError(e)
} catch (e: InvocationTargetException) {
throw AssertionError(e)
// https://github.com/square/okhttp/issues/5587
val cause = e.cause
when {
cause is NullPointerException && cause.message == "ssl == null" -> null
else -> throw AssertionError(e)
}
}
}

Expand Down

0 comments on commit 6ba23dc

Please sign in to comment.