From f82b27589639891b124211efb4d395d901b31755 Mon Sep 17 00:00:00 2001 From: tsushanth <78000697+tsushanth@users.noreply.github.com> Date: Sat, 4 Jul 2026 20:15:06 -0700 Subject: [PATCH] Handle null return from ExtendedSSLSession.getRequestedServerNames On Android SDK 27/28, getRequestedServerNames() can return null instead of an empty list (see google/conscrypt#977). Guard with ?: emptyList() so MockWebServer no longer throws NPE on affected emulator versions. Fixes #9523 --- .../kotlin/okhttp3/internal/platform/Platform.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/platform/Platform.kt b/okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/platform/Platform.kt index f33d97972b94..9ccde5c61b0a 100644 --- a/okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/platform/Platform.kt +++ b/okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/platform/Platform.kt @@ -132,7 +132,7 @@ open class Platform { open fun getHandshakeServerNames(sslSocket: SSLSocket): List { val session = sslSocket.session as? ExtendedSSLSession ?: return listOf() return try { - session.requestedServerNames.mapNotNull { (it as? SNIHostName)?.asciiName } + (session.requestedServerNames ?: emptyList()).mapNotNull { (it as? SNIHostName)?.asciiName } } catch (_: UnsupportedOperationException) { // UnsupportedOperationException – if the underlying provider does not implement the operation // https://github.com/bcgit/bc-java/issues/1773