IllegalStateException: Shutdown in progress in XMemcachedClient.shutdown()

113 views
Skip to first unread message

jy00807322

unread,
Sep 20, 2013, 1:03:05 PM9/20/13
to xmemc...@googlegroups.com
Hi All,
I am getting an exception in my XMemcached related code. Can anyone help me to fix this expcetion? Thank you very much for advanced!
(Sorry I could not find a way to edit my old post so have to post a new one)

We have a method which has below logic:

MemcachedClient client...
client.shutdown();

if(client.isShutdown == true ...) {
    ...
    System.exit(0);
}

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!

jy00807322

unread,
Sep 23, 2013, 10:11:47 AM9/23/13
to xmemc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages