Skip to content

Handle null return from ExtendedSSLSession.getRequestedServerNames on Android SDK 27/28#9525

Open
tsushanth wants to merge 1 commit into
square:masterfrom
tsushanth:fix/9523-requested-server-names-null
Open

Handle null return from ExtendedSSLSession.getRequestedServerNames on Android SDK 27/28#9525
tsushanth wants to merge 1 commit into
square:masterfrom
tsushanth:fix/9523-requested-server-names-null

Conversation

@tsushanth

Copy link
Copy Markdown

Fixes #9523.

On Android SDK 27 and 28, ExtendedSSLSession.getRequestedServerNames() can return null instead of an empty list (upstream bug: google/conscrypt#977). This causes a NullPointerException in MockWebServer when recording requestedServerNames on a RecordedRequest.

Change: one-line null guard in Platform.getHandshakeServerNames — replace direct .mapNotNull call with (session.requestedServerNames ?: emptyList()).mapNotNull { ... }. Already catches UnsupportedOperationException in the same block, so the null case fits the same defensive pattern.

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 square#9523
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhandled null return from ExtendedSSLSession.getRequestedServerNames

2 participants