MINOR: log which signals are handled on startup
Reviewers: Gwen Shapira
@@ -23,6 +23,8 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.Arrays;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -30,6 +32,8 @@ public class LoggingSignalHandler {
private static final Logger log = LoggerFactory.getLogger(LoggingSignalHandler.class);
+ private static final List<String> SIGNALS = Arrays.asList("TERM", "INT", "HUP");
+
private final Constructor<?> signalConstructor;
private final Class<?> signalHandlerClass;
private final Class<?> signalClass;
@@ -61,9 +65,11 @@ public class LoggingSignalHandler {
*/
public void register() throws ReflectiveOperationException {
Map<String, Object> jvmSignalHandlers = new ConcurrentHashMap<>();
- register("TERM", jvmSignalHandlers);
- register("INT", jvmSignalHandlers);
- register("HUP", jvmSignalHandlers);
+
+ for (String signal : SIGNALS) {
+ register(signal, jvmSignalHandlers);
+ }
+ log.info("Registered signal handlers for " + String.join(", ", SIGNALS));
}
private Object createSignalHandler(final Map<String, Object> jvmSignalHandlers) {
