Closed brett-smith closed 11 months ago
You are right, the sample code is somehow "broken". Even though I wouldn't say broken, because it relied on a side effect caused by the sending thread-pool using non-daemon threads.
I think dbus-java should never block. I always hate libraries causing my applications to hang or to force me doing weird stuff to let it stop properly. The user of the library should control when the application should block or terminate immediately. If it should block: take care that is does by yourself and ensure a proper shutdown if the condition to stop is reached.
I therefore updated the example in the documentation and added the code as running example in dbus-examples module.
The updated example simple provides a way to close the application remotely using a CountDownLatch
. Anyway, a application developer should replace that with something more suitable (allowing anyone to kill you application remotely is not a good idea most of the time).
The example in the Maven site documentation, https://hypfvieh.github.io/dbus-java/exporting-objects.html, no longer works correctly without changes. It simply exits immediately.
It appears this was broken by https://github.com/hypfvieh/dbus-java/commit/7219193242a3c6442ff53c10555071f53e4e7a58
A
Thread.sleep(999999)
does the trick, but is not ideal. I'm not sure what the right way to fix this would be.