From 0ca4c82dd1032625831a5814ea2ddcf165029bdc Mon Sep 17 00:00:00 2001 From: Adam Speakman Date: Thu, 6 Feb 2014 12:06:17 +1300 Subject: [PATCH] Fix for NPE when the OpenSSLSocketImpl returns null from getNpnSelectedProtocol. --- .../src/main/java/com/squareup/okhttp/internal/Platform.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/okhttp-protocols/src/main/java/com/squareup/okhttp/internal/Platform.java b/okhttp-protocols/src/main/java/com/squareup/okhttp/internal/Platform.java index eee229533e58..ed4ba10e1cb4 100644 --- a/okhttp-protocols/src/main/java/com/squareup/okhttp/internal/Platform.java +++ b/okhttp-protocols/src/main/java/com/squareup/okhttp/internal/Platform.java @@ -293,7 +293,9 @@ private Android( byte[] alpnResult = (byte[]) getAlpnSelectedProtocol.invoke(socket); if (alpnResult != null) return ByteString.of(alpnResult); } - return ByteString.of((byte[]) getNpnSelectedProtocol.invoke(socket)); + byte[] npnResult = (byte[]) getNpnSelectedProtocol.invoke(socket); + if (npnResult == null) return null; + return ByteString.of(npnResult); } catch (InvocationTargetException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) {