public void removeShutdownHook() { if (shutDownHook != null) { Runtime.getRuntime().removeShutdownHook(shutDownHook); } }
private void removeShutdownHook(Shutdown shutdownHook) { try { Runtime.getRuntime().removeShutdownHook(shutdownHook); } catch (Exception e) { } }
private void removeShutDownHook(Thread shutdownHook) { if (shutdownHook != null) { try { Runtime.getRuntime().removeShutdownHook(shutdownHook); } catch (Exception e) { } } }
/** * Unregister the ShutdownHook */ public void unregister() { if (registered.get() && registered.compareAndSet(true, false)) { Runtime.getRuntime().removeShutdownHook(getDubboShutdownHook()); } }
/** When true, <code>Runtime.getRuntime().halt(0);</code> is used when the JVM shuts down. This prevents Swing shutdown hooks * from causing a deadlock and keeping the JVM alive indefinitely. Default is true. */ public void setHaltOnShutdown (boolean halt) { if (halt) { if (shutdownHook != null) return; shutdownHook = new Thread() { public void run () { Runtime.getRuntime().halt(0); // Because fuck you, deadlock causing Swing shutdown hooks. } }; Runtime.getRuntime().addShutdownHook(shutdownHook); } else if (shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(shutdownHook); shutdownHook = null; } }
/** When true, <code>Runtime.getRuntime().halt(0);</code> is used when the JVM shuts down. This prevents Swing shutdown hooks * from causing a deadlock and keeping the JVM alive indefinitely. Default is true. */ public void setHaltOnShutdown (boolean halt) { if (halt) { if (shutdownHook != null) return; shutdownHook = new Thread() { public void run () { Runtime.getRuntime().halt(0); // Because fuck you, deadlock causing Swing shutdown hooks. } }; Runtime.getRuntime().addShutdownHook(shutdownHook); } else if (shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(shutdownHook); shutdownHook = null; } }
/** Kills this process, and kills the stream gobblers waiting on it. */ public void kill() { Runtime.getRuntime().removeShutdownHook(shutdownHoook); shutdownHoook.run(); }
/** * Unregister the ShutdownHook */ public void unregister() { if (registered.get() && registered.compareAndSet(true, false)) { Runtime.getRuntime().removeShutdownHook(getDubboShutdownHook()); } }
/** When true, <code>Runtime.getRuntime().halt(0);</code> is used when the JVM shuts down. This prevents Swing shutdown hooks * from causing a deadlock and keeping the JVM alive indefinitely. Default is true. */ public void setHaltOnShutdown (boolean halt) { if (halt) { if (shutdownHook != null) return; shutdownHook = new Thread() { public void run () { Runtime.getRuntime().halt(0); // Because fuck you, deadlock causing Swing shutdown hooks. } }; Runtime.getRuntime().addShutdownHook(shutdownHook); } else if (shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(shutdownHook); shutdownHook = null; } }
/** When true, <code>Runtime.getRuntime().halt(0);</code> is used when the JVM shuts down. This prevents Swing shutdown hooks * from causing a deadlock and keeping the JVM alive indefinitely. Default is true. */ public void setHaltOnShutdown (boolean halt) { if (halt) { if (shutdownHook != null) return; shutdownHook = new Thread() { public void run () { Runtime.getRuntime().halt(0); // Because fuck you, deadlock causing Swing shutdown hooks. } }; Runtime.getRuntime().addShutdownHook(shutdownHook); } else if (shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(shutdownHook); shutdownHook = null; } }
private synchronized void removeHook() { if (null == shutdownHook) return; ShutdownThread tmp = shutdownHook; shutdownHook = null; // Remove shutdown hook to avoid reference retention try { Runtime.getRuntime().removeShutdownHook(tmp); log.debug("Removed shutdown hook {}", tmp); } catch (IllegalStateException e) { log.warn("Failed to remove shutdown hook", e); } }
@Override public boolean removeShutdownHook(Runnable shutdownHook) { Thread shutdownHookThread = null; if (!(shutdownHook instanceof Thread)) { shutdownHookThread = new Thread(shutdownHook); } else shutdownHookThread = (Thread) shutdownHook; return Runtime.getRuntime().removeShutdownHook(shutdownHookThread); } }
public void stop() { LOG.warn("Shutting down Zuul."); serverGroup.stop(); // remove the shutdown hook that was added when the proxy was started, since it has now been stopped try { Runtime.getRuntime().removeShutdownHook(jvmShutdownHook); } catch (IllegalStateException e) { // ignore -- IllegalStateException means the VM is already shutting down } LOG.warn("Completed zuul shutdown."); }
/** * Close this application context, destroying all beans in its bean factory. * <p>Delegates to {@code doClose()} for the actual closing procedure. * Also removes a JVM shutdown hook, if registered, as it's not needed anymore. * @see #doClose() * @see #registerShutdownHook() */ @Override public void close() { synchronized (this.startupShutdownMonitor) { doClose(); // If we registered a JVM shutdown hook, we don't need it anymore now: // We've already explicitly closed the context. if (this.shutdownHook != null) { try { Runtime.getRuntime().removeShutdownHook(this.shutdownHook); } catch (IllegalStateException ex) { // ignore - VM is already shutting down } } } }
private void removeShutdownHook() { if ( shutdownHook != null ) { if ( !Runtime.getRuntime().removeShutdownHook( shutdownHook ) ) { log.warn( "Unable to remove shutdown hook" ); } } }
public synchronized void destroy() { running = false; if (executorService != null) { executorService.shutdown(); } if (canalMQProducer != null) { canalMQProducer.stop(); } if (shutdownThread != null) { Runtime.getRuntime().removeShutdownHook(shutdownThread); shutdownThread = null; } }
/** * Close this file resolver, this is a blocking operation. */ public void close() throws IOException { synchronized (this) { if (shutdownHook != null) { // May throw IllegalStateException if called from other shutdown hook so ignore that try { Runtime.getRuntime().removeShutdownHook(shutdownHook); } catch (IllegalStateException ignore) { } } } deleteCacheDir(); }
public void stop() { LOG.warn("Shutting down Zuul."); serverGroup.stop(); // remove the shutdown hook that was added when the proxy was started, since it has now been stopped try { Runtime.getRuntime().removeShutdownHook(jvmShutdownHook); } catch (IllegalStateException e) { // ignore -- IllegalStateException means the VM is already shutting down } LOG.warn("Completed zuul shutdown."); }
@After public void tearDown() { Runtime.getRuntime().removeShutdownHook(logger.exitHook()); }
@Test public void shouldRegisterItselfAsExitHook() { logger = new SubprocessLogger(new DefaultCurrentProcess()); logger.registerAsExitHook("foo"); try { Runtime.getRuntime().addShutdownHook(logger.exitHook()); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Hook previously registered")); } finally { Runtime.getRuntime().removeShutdownHook(logger.exitHook()); } } }