From 9690e064bc3cfdb592e54594c330185ab8a0c2a1 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 9 Mar 2017 15:44:27 +1100 Subject: [PATCH 1/2] increase test timeout --- .../org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java | 2 +- .../test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) 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; From 9f9e1ab19027dbcbb014771c9662129308262fce Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 9 Mar 2017 15:56:54 +1100 Subject: [PATCH 2/2] Issue #1374 Stop on Failure --- .../util/component/AbstractLifeCycle.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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); + } + } + }; }