summaryrefslogtreecommitdiffstats
path: root/infra/impl
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-03-07 15:25:17 +0100
committerMarek Gradzki <mgradzki@cisco.com>2018-03-07 15:26:18 +0100
commit146f51f09ff1c53d25b233035282286b733d0577 (patch)
treeca1325f863c10f81000c89c79538696ab3a1b967 /infra/impl
parenta8b9c1ad9df23ff33beea1ba80caadcca19391c5 (diff)
ShutdownHandlerImpl: remove registered components after shutdown is performed
Prevents invoking AutoCloseable.close(), which might not be idempotent. Change-Id: Id28200fb68a4c6e38878cf4f0b8aaee298dbc37b Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/impl')
-rw-r--r--infra/impl/src/main/java/io/fd/honeycomb/impl/ShutdownHandlerImpl.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/infra/impl/src/main/java/io/fd/honeycomb/impl/ShutdownHandlerImpl.java b/infra/impl/src/main/java/io/fd/honeycomb/impl/ShutdownHandlerImpl.java
index f622a603b..d7fd78a1e 100644
--- a/infra/impl/src/main/java/io/fd/honeycomb/impl/ShutdownHandlerImpl.java
+++ b/infra/impl/src/main/java/io/fd/honeycomb/impl/ShutdownHandlerImpl.java
@@ -20,9 +20,11 @@ import io.fd.honeycomb.data.init.ShutdownHandler;
import java.util.Deque;
import java.util.LinkedList;
import javax.annotation.Nonnull;
+import javax.annotation.concurrent.NotThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@NotThreadSafe
public final class ShutdownHandlerImpl implements ShutdownHandler {
private static final Logger LOG = LoggerFactory.getLogger(ShutdownHandlerImpl.class);
@@ -70,5 +72,8 @@ public final class ShutdownHandlerImpl implements ShutdownHandler {
LOG.warn("Unable to close component {}", closeable.getName(), e);
}
});
+ // AutoCloseable.close() might not be idempotent, so remove registered components
+ // to prevent multiple invocations:
+ components.clear();
}
}