In this case we are always getting a IllegalStateException: Shutdown in progress
at java.lang.ApplicationShutdownHooks.remove(ApplicationShutdownHooks.java:82)
I found the related function is:
MemcachedClient class:
public final boolean isShutdown() {
return this.shutdown;
}
and
public final void shutdown() throws IOException {
...
this.shutdown = true;
...
if (!isHutdownHookCalled) {
Runtime.getRuntime().removeShutdownHook(shutdownHookThread);
}
}
Seems this.shutdown turns to true before it is really shutdown. But in our code we would stop the JVM if client.isShutdown == true;
Therefore sometimes the JVM has shutdown but removeShutdownHook(shutdownHookThread) is still working. The shutdownHookThread turns to null and JVM throws IllegalStateException.
We tried to add a sleep before system.exit(0); Still getting exceptions
sometimes. Is there anyway we can fix this exception? Thank you very
much!