From 23e2d259f3a0bfa9666b497ae68a79087fd9aa73 Mon Sep 17 00:00:00 2001 From: Tomas Hofman Date: Thu, 13 Feb 2020 09:43:26 +0100 Subject: [PATCH] Catch IllegalStateException during shutdown hook removal attempt... ...when shutdown is already in progress Signed-off-by: Tomas Hofman --- .../main/java/io/jaegertracing/internal/JaegerTracer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerTracer.java b/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerTracer.java index fcc2a2704..9a26c96d5 100644 --- a/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerTracer.java +++ b/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerTracer.java @@ -227,7 +227,11 @@ public void close() { reporter.close(); sampler.close(); if (shutdownHook != null) { - Runtime.getRuntime().removeShutdownHook(shutdownHook); + try { + Runtime.getRuntime().removeShutdownHook(shutdownHook); + } catch (IllegalStateException e) { + log.info("Can't remove shutdown hook, shutdown already in progress."); + } } }