aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@verizonmedia.com>2019-01-31 23:29:22 +0100
committerHåkon Hallingstad <hakon@verizonmedia.com>2019-01-31 23:29:22 +0100
commit1e8a2974fc3e7b756c966eda3cc3d94efd850f64 (patch)
tree40f486594da2f1dd949c550b0926e409608778df /vespajlib
parent04221b18021faeb53754b4cec538307b62c9d558 (diff)
Remove duplicate CatchSigTerm from vespajlib
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/system/CatchSigTerm.java70
-rw-r--r--vespajlib/src/test/java/com/yahoo/system/CatchSignalsTestCase.java18
2 files changed, 0 insertions, 88 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/system/CatchSigTerm.java b/vespajlib/src/main/java/com/yahoo/system/CatchSigTerm.java
deleted file mode 100644
index e1f037f5d98..00000000000
--- a/vespajlib/src/main/java/com/yahoo/system/CatchSigTerm.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.system;
-
-import java.lang.reflect.*;
-
-// import sun.misc.Signal;
-// import sun.misc.SignalHandler;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class CatchSigTerm {
- /**
- * Sets up a signal handler for SIGTERM, where a given AtomicBoolean
- * gets a true value when the TERM signal is caught.
- *
- * Callers basically have two options for acting on the TERM signal:
- *
- * They may choose to synchronize and wait() on this variable,
- * and they will be notified when it changes state to true. To avoid
- * problems with spurious wakeups, use a while loop and wait()
- * again if the state is still false. As soon as the caller has been
- * woken up and the state is true, the application should exit as
- * soon as possible.
- *
- * They may also choose to poll the state of this variable. As soon
- * as its state becomes true, the signal has been received, and the
- * application should exit as soon as possible.
- *
- * @param signalCaught set to false initially, will be set to true when SIGTERM is caught.
- */
- @SuppressWarnings("rawtypes")
- public static void setup(final AtomicBoolean signalCaught) {
- signalCaught.set(false);
- try {
- Class shc = Class.forName("sun.misc.SignalHandler");
- Class ssc = Class.forName("sun.misc.Signal");
-
- InvocationHandler ihandler = new InvocationHandler() {
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- synchronized (signalCaught) {
- signalCaught.set(true);
- signalCaught.notifyAll();
- }
- return null;
- }
- };
- Object shandler = Proxy.newProxyInstance(CatchSigTerm.class.getClassLoader(),
- new Class[] { shc },
- ihandler);
- Constructor[] c = ssc.getDeclaredConstructors();
- assert c.length == 1;
- Object sigterm = c[0].newInstance("TERM");
- Method m = findMethod(ssc, "handle");
- assert m != null; // "NoSuchMethodException"
- m.invoke(null, sigterm, shandler);
- } catch (ClassNotFoundException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
- System.err.println("FAILED setting up signal catching: "+e);
- }
- }
-
- @SuppressWarnings("rawtypes")
- private static Method findMethod(Class c, String name) {
- for (Method m : c.getDeclaredMethods()) {
- if (m.getName().equals(name)) {
- return m;
- }
- }
- return null;
- }
-}
diff --git a/vespajlib/src/test/java/com/yahoo/system/CatchSignalsTestCase.java b/vespajlib/src/test/java/com/yahoo/system/CatchSignalsTestCase.java
deleted file mode 100644
index 13879115555..00000000000
--- a/vespajlib/src/test/java/com/yahoo/system/CatchSignalsTestCase.java
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.system;
-
-import org.junit.Test;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * @author arnej27959
- */
-public class CatchSignalsTestCase {
-
- @Test
- public void testThatSetupCompiles() {
- CatchSigTerm.setup(new AtomicBoolean(false));
- }
-
-}