java.lang.InterruptedException

Java.net JIRA | oleksiys | 3 years ago
  1. 0

    I'm working with a jersey server and want to be sure that when the server is terminated (usually via SIGTERM), all currently running requests are completed gracefully. If volume is high enough, there will likely be data loss if I don't do this. So I'm trying to call HttpServer.shutdown() from a runtime shutdown hook. I think it is working correctly, except for one problem. CompletionHandler.failed() is invoked, with an InterruptedException. shutdownNow is in the stack trace, so it seems like there is just some logical error occurring after the shutdown itself has finished: {code} java.lang.InterruptedException at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1302) at org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerGet(SafeFutureImpl.java:354) at org.glassfish.grizzly.impl.SafeFutureImpl.get(SafeFutureImpl.java:265) at org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:181) at org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:287) at org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerSet(SafeFutureImpl.java:383) at org.glassfish.grizzly.impl.SafeFutureImpl.result(SafeFutureImpl.java:112) at org.glassfish.grizzly.http.server.HttpServer.shutdownNow(HttpServer.java:458) at org.glassfish.grizzly.http.server.HttpServer$1.completed(HttpServer.java:384) at org.glassfish.grizzly.http.server.HttpServer$1.completed(HttpServer.java:376) at org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:199) at org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:287) at org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerSet(SafeFutureImpl.java:383) at org.glassfish.grizzly.impl.SafeFutureImpl.result(SafeFutureImpl.java:112) at org.glassfish.grizzly.http.server.NetworkListener$1$1.completed(NetworkListener.java:698) at org.glassfish.grizzly.http.server.NetworkListener$1$1.completed(NetworkListener.java:693) at org.glassfish.grizzly.http.server.HttpServerFilter.prepareForShutdown(HttpServerFilter.java:328) at org.glassfish.grizzly.http.server.NetworkListener$1.shutdownRequested(NetworkListener.java:704) at org.glassfish.grizzly.nio.GracefulShutdownRunner.run(GracefulShutdownRunner.java:93) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:744) {code} I boiled it down to this test case which does not use jersey or a shutdown hook. It's very simple and the same exception occurs (in fact, the above is copied from the output of this program): {code} public class Server { public static void main(String[] args) throws IOException { HttpServer server = HttpServer.createSimpleServer(); server.start(); try { Thread.sleep(5000); } catch (InterruptedException ex) {} shutdown(server); } public static void shutdown (HttpServer server) { final boolean [] done = {false}; server.shutdown().addCompletionHandler(new EmptyCompletionHandler<HttpServer>() { public void completed (HttpServer arg) { System.out.println("Shutdown completed"); done[0] = true; } public void failed (Throwable error) { System.out.println("Shutdown failed"); error.printStackTrace(System.out); done[0] = true; } }); while (!done[0]) { try { Thread.sleep(100); } catch (InterruptedException ex) {} } System.out.println("Goodbye"); } } {code}

    Java.net JIRA | 3 years ago | oleksiys
    java.lang.InterruptedException
  2. 0

    GitHub comment 1635#251458269

    GitHub | 2 months ago | tcarette
    java.lang.InterruptedException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Adding new files while scanning could raise a non caught exception

    GitHub | 2 years ago | dadoonet
    org.elasticsearch.ElasticsearchIllegalStateException: Future got interrupted

  1. tyson925 10 times, last 2 months ago
  2. tyson925 8 times, last 3 months ago
  3. Handemelindo 2 times, last 3 months ago
5 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.InterruptedException

    No message provided

    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly()
  2. Java RT
    AbstractQueuedSynchronizer.acquireSharedInterruptibly
    1. java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1302)
    1 frame
  3. Grizzly
    SafeFutureImpl.result
    1. org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerGet(SafeFutureImpl.java:354)
    2. org.glassfish.grizzly.impl.SafeFutureImpl.get(SafeFutureImpl.java:265)
    3. org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:181)
    4. org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:287)
    5. org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerSet(SafeFutureImpl.java:383)
    6. org.glassfish.grizzly.impl.SafeFutureImpl.result(SafeFutureImpl.java:112)
    6 frames
  4. Grizzly Server
    HttpServer$1.completed
    1. org.glassfish.grizzly.http.server.HttpServer.shutdownNow(HttpServer.java:458)
    2. org.glassfish.grizzly.http.server.HttpServer$1.completed(HttpServer.java:384)
    3. org.glassfish.grizzly.http.server.HttpServer$1.completed(HttpServer.java:376)
    3 frames
  5. Grizzly
    SafeFutureImpl.result
    1. org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:199)
    2. org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:287)
    3. org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerSet(SafeFutureImpl.java:383)
    4. org.glassfish.grizzly.impl.SafeFutureImpl.result(SafeFutureImpl.java:112)
    4 frames
  6. Grizzly Server
    NetworkListener$1.shutdownRequested
    1. org.glassfish.grizzly.http.server.NetworkListener$1$1.completed(NetworkListener.java:698)
    2. org.glassfish.grizzly.http.server.NetworkListener$1$1.completed(NetworkListener.java:693)
    3. org.glassfish.grizzly.http.server.HttpServerFilter.prepareForShutdown(HttpServerFilter.java:328)
    4. org.glassfish.grizzly.http.server.NetworkListener$1.shutdownRequested(NetworkListener.java:704)
    4 frames
  7. Grizzly
    GracefulShutdownRunner.run
    1. org.glassfish.grizzly.nio.GracefulShutdownRunner.run(GracefulShutdownRunner.java:93)
    1 frame
  8. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    3. java.lang.Thread.run(Thread.java:744)
    3 frames