// Note also called reflectively by BrooklynLeakListener @Beta public static int terminateAll() { int closed = 0, dangling = 0; for (LocalManagementContext context : getInstances()) { try { context.terminate(); closed++; } catch (Throwable t) { Exceptions.propagateIfFatal(t); log.warn("Failed to terminate management context", t); dangling++; } } if (dangling > 0) return -dangling; return closed; }
@Override protected void finalize() { terminate(); }