Calling Node.shutdown from a MessageListener throws exception (and doesn't shutdown)

asked 2018-03-08 10:42:05 -0600

paol gravatar image

What the title says. Looks likely to be a threading problem, since onNewMessage is known to run on a separate thread and the exception happens in a java.util.concurrent primitive.

Using rosjava 0.3.5

 Exception in thread "pool-1-thread-13" org.ros.exception.RosRuntimeException: java.lang.InterruptedException
        at org.ros.internal.node.client.Registrar.shutdown(Registrar.java:358)
        at org.ros.internal.node.DefaultNode.shutdown(DefaultNode.java:426)
        at sensei.ros.publishernode.TrackletListener.onNewMessage(TrackletListener.java:76)
        at sensei.ros.publishernode.TrackletListener.onNewMessage(TrackletListener.java:28)
        at org.ros.internal.transport.queue.MessageDispatcher$1.run(MessageDispatcher.java:125)
        at org.ros.internal.transport.queue.MessageDispatcher$1.run(MessageDispatcher.java:122)
        at org.ros.concurrent.EventDispatcher.loop(EventDispatcher.java:43)
        at org.ros.concurrent.CancellableLoop.run(CancellableLoop.java:56)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.InterruptedException
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1326)
        at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:277)
        at org.ros.concurrent.RetryingExecutorService.shutdown(RetryingExecutorService.java:153)
        at org.ros.internal.node.client.Registrar.shutdown(Registrar.java:356)
        ... 10 more

So I guess 2 questions:

  • Is this a bug or limitation by design (if the latter, the documentation of shutdown should probably mention this)
  • How else can I shutdown a node cleanly. I know I could call System.exit but I assume Node.shutdown is doing some important cleanup, otherwise it wouldn't exist?
edit retag flag offensive close merge delete

Comments

Hi @paol. This doesn't look like a design limitation, but a genuine bug report. Please feel free to open an issue in rosjava_core with any information that you have. Shutting down a node using the method makes the master unregister it, which is desirable. You can probably still call exit otherwise

jubeira gravatar image jubeira  ( 2018-03-08 13:02:05 -0600 )edit

Thanks. I've reported it: https://github.com/rosjava/rosjava_co...

paol gravatar image paol  ( 2018-03-09 03:36:49 -0600 )edit