Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation example does not work correctly. #236

Closed
brett-smith opened this issue Oct 3, 2023 · 1 comment
Closed

Documentation example does not work correctly. #236

brett-smith opened this issue Oct 3, 2023 · 1 comment

Comments

@brett-smith
Copy link
Contributor

brett-smith commented Oct 3, 2023

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 7219193

A Thread.sleep(999999) does the trick, but is not ideal. I'm not sure what the right way to fix this would be.

@hypfvieh
Copy link
Owner

hypfvieh commented Oct 4, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants