From 10a5270e79c134462ed3744a5322ccbdb8fecc92 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 22 May 2014 10:28:38 +0900 Subject: [PATCH] Fix NPE --- .../handler/ssl/JdkSslClientContext.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/handler/src/main/java/io/netty/handler/ssl/JdkSslClientContext.java b/handler/src/main/java/io/netty/handler/ssl/JdkSslClientContext.java index b6a64aba13..07a0d1db98 100644 --- a/handler/src/main/java/io/netty/handler/ssl/JdkSslClientContext.java +++ b/handler/src/main/java/io/netty/handler/ssl/JdkSslClientContext.java @@ -106,18 +106,22 @@ public final class JdkSslClientContext extends JdkSslContext { super(ciphers); - if (nextProtocols != null && nextProtocols.iterator().hasNext() && !JettyNpnSslEngine.isAvailable()) { - throw new SSLException("NPN/ALPN unsupported: " + nextProtocols); - } - - List nextProtoList = new ArrayList(); - for (String p: nextProtocols) { - if (p == null) { - break; + if (nextProtocols != null && nextProtocols.iterator().hasNext()) { + if (!JettyNpnSslEngine.isAvailable()) { + throw new SSLException("NPN/ALPN unsupported: " + nextProtocols); } - nextProtoList.add(p); + + List nextProtoList = new ArrayList(); + for (String p: nextProtocols) { + if (p == null) { + break; + } + nextProtoList.add(p); + } + this.nextProtocols = Collections.unmodifiableList(nextProtoList); + } else { + this.nextProtocols = Collections.emptyList(); } - this.nextProtocols = Collections.unmodifiableList(nextProtoList); try { if (certChainFile == null) {