Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handling InterruptedExceptions in the HystrixMetricsStreamServlet

Some environments like spring boots embedded Tomcat interrupt the worker threads on shutdown. Interupting a thread is the Java way to politely ask it to gracefully stop doing long running things. Since serving an event stream is a long running thing, we should stop sending the stream and stop polling, whenever an InterruptedException occures.
  • Loading branch information...
commit e6d8cd6dfc864b37da9c177c6e9da8c9ce529fd1 1 parent 2972125
@BGehrels BGehrels authored
View
4 ...nt-stream/src/main/java/com/netflix/hystrix/contrib/metrics/eventstream/HystrixMetricsStreamServlet.java
@@ -150,6 +150,10 @@ private void handleRequest(HttpServletRequest request, HttpServletResponse respo
// now wait the 'delay' time
Thread.sleep(delay);
}
+ } catch (InterruptedException e) {
+ poller.shutdown();
+ logger.debug("InterruptedException. Will stop polling.");
+ Thread.currentThread().interrupt();
} catch (IOException e) {
poller.shutdown();
// debug instead of error as we expect to get these whenever a client disconnects or network issue occurs
Please sign in to comment.
Something went wrong with that request. Please try again.