diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java index 9553cc2338b..29f2430d3df 100644 --- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java +++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java @@ -75,7 +75,7 @@ public abstract class AbstractConnectHandlerTest protected Socket newSocket() throws IOException { Socket socket = new Socket("localhost", proxyConnector.getLocalPort()); - socket.setSoTimeout(5000); + socket.setSoTimeout(20000); return socket; } } diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java index 455e450abaa..ca040509897 100644 --- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java +++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java @@ -18,11 +18,9 @@ package org.eclipse.jetty.proxy; -import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java index 950ccb07ab0..402a58cbcbc 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java @@ -234,4 +234,23 @@ public abstract class AbstractLifeCycle implements LifeCycle @Override public void lifeCycleStopped(LifeCycle event) {} @Override public void lifeCycleStopping(LifeCycle event) {} } + + /** + * A LifeCycle Listener that will call stop if any failures are notified. + */ + public static final LifeCycle.Listener STOP_ON_FAILURE = new AbstractLifeCycleListener() + { + @Override + public void lifeCycleFailure(LifeCycle lifecycle, Throwable cause) + { + try + { + lifecycle.stop(); + } + catch(Exception e) + { + cause.addSuppressed(e); + } + } + }; }