From aeb3a2348219222d5bd21c70551704b52d293a56 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 11 Jun 2012 14:25:51 +0200 Subject: [PATCH] Making sure that cancelling the attempt to connect closes the channel. --- .../org/eclipse/jetty/spdy/SPDYClient.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java index 071ed8ea022..eb2a811b096 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java @@ -101,7 +101,7 @@ public class SPDYClient channel.socket().setTcpNoDelay(true); channel.configureBlocking(false); - SessionPromise result = new SessionPromise(this, listener); + SessionPromise result = new SessionPromise(channel, this, listener); channel.connect(address); factory.selector.register(channel, result); @@ -419,14 +419,31 @@ public class SPDYClient private static class SessionPromise extends Promise { + private final SocketChannel channel; private final SPDYClient client; private final SessionFrameListener listener; - private SessionPromise(SPDYClient client, SessionFrameListener listener) + private SessionPromise(SocketChannel channel, SPDYClient client, SessionFrameListener listener) { + this.channel = channel; this.client = client; this.listener = listener; } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) + { + try + { + super.cancel(mayInterruptIfRunning); + channel.close(); + return true; + } + catch (IOException x) + { + return true; + } + } } private static class ClientSPDYAsyncConnectionFactory implements AsyncConnectionFactory