From 756b13700b5269d27c979a1df916c439d704948d Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 12 Dec 2012 18:34:22 +0100 Subject: [PATCH] Handling properly connect exceptions, notifying the failure to the websocket client. --- .../internal/io/WebSocketClientSelectorManager.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/io/WebSocketClientSelectorManager.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/io/WebSocketClientSelectorManager.java index 162ee46c5d8..906f3ce8b31 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/io/WebSocketClientSelectorManager.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/internal/io/WebSocketClientSelectorManager.java @@ -22,7 +22,6 @@ import java.io.IOException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.concurrent.Executor; - import javax.net.ssl.SSLEngine; import org.eclipse.jetty.io.ByteBufferPool; @@ -58,6 +57,11 @@ public class WebSocketClientSelectorManager extends SelectorManager return sslContextFactory; } + public void setSslContextFactory(SslContextFactory sslContextFactory) + { + this.sslContextFactory = sslContextFactory; + } + @Override public Connection newConnection(final SocketChannel channel, EndPoint endPoint, final Object attachment) throws IOException { @@ -71,6 +75,7 @@ public class WebSocketClientSelectorManager extends SelectorManager if ("wss".equalsIgnoreCase(scheme)) { // Encrypted "wss://" + SslContextFactory sslContextFactory = getSslContextFactory(); if (sslContextFactory != null) { SSLEngine engine = newSSLEngine(sslContextFactory,channel); @@ -127,8 +132,10 @@ public class WebSocketClientSelectorManager extends SelectorManager return connection; } - public void setSslContextFactory(SslContextFactory sslContextFactory) + @Override + protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment) { - this.sslContextFactory = sslContextFactory; + DefaultWebSocketClient client = (DefaultWebSocketClient)attachment; + client.failed(ex); } }