From b6e603a467bf5670d94055d973b540968c00e328 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 17 Jan 2017 11:31:03 +0100 Subject: [PATCH] Issue #486 - JDK 9 ALPN implementation. Prevented NPEs in case there is no ALPN provider. --- .../jetty/alpn/java/client/JDK9ClientALPNProcessor.java | 3 ++- .../jetty/alpn/java/server/JDK9ServerALPNProcessor.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jetty-alpn/jetty-alpn-java-client/src/main/java/org/eclipse/jetty/alpn/java/client/JDK9ClientALPNProcessor.java b/jetty-alpn/jetty-alpn-java-client/src/main/java/org/eclipse/jetty/alpn/java/client/JDK9ClientALPNProcessor.java index fff7072b959..b06fc76b275 100644 --- a/jetty-alpn/jetty-alpn-java-client/src/main/java/org/eclipse/jetty/alpn/java/client/JDK9ClientALPNProcessor.java +++ b/jetty-alpn/jetty-alpn-java-client/src/main/java/org/eclipse/jetty/alpn/java/client/JDK9ClientALPNProcessor.java @@ -44,7 +44,8 @@ public class JDK9ClientALPNProcessor implements ALPNProcessor.Client try { ALPN.ClientProvider provider = (ALPN.ClientProvider)ALPN.get(sslEngine); - provider.selected(sslEngine.getApplicationProtocol()); + if (provider != null) + provider.selected(sslEngine.getApplicationProtocol()); } catch (SSLException x) { diff --git a/jetty-alpn/jetty-alpn-java-server/src/main/java/org/eclipse/jetty/alpn/java/server/JDK9ServerALPNProcessor.java b/jetty-alpn/jetty-alpn-java-server/src/main/java/org/eclipse/jetty/alpn/java/server/JDK9ServerALPNProcessor.java index 44241ff3f3e..34c9424e9ae 100644 --- a/jetty-alpn/jetty-alpn-java-server/src/main/java/org/eclipse/jetty/alpn/java/server/JDK9ServerALPNProcessor.java +++ b/jetty-alpn/jetty-alpn-java-server/src/main/java/org/eclipse/jetty/alpn/java/server/JDK9ServerALPNProcessor.java @@ -46,7 +46,7 @@ public class JDK9ServerALPNProcessor implements ALPNProcessor.Server, SslHandsha if (LOG.isDebugEnabled()) LOG.debug("ALPN selecting among client{}", protocols); ALPN.ServerProvider provider = (ALPN.ServerProvider)ALPN.remove(sslEngine); - return provider.select(protocols); + return provider == null ? "" : provider.select(protocols); } catch (SSLException x) {