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

NPE in org.freedesktop.dbus.connections.AbstractConnection.internalDisconnect(IOException) prevents JVM shutdown #234

Closed
GeorgBisseling opened this issue Sep 21, 2023 · 4 comments

Comments

@GeorgBisseling
Copy link

Version dbus-java-core-4.2.1.jar

When experimenting with bluez-dbus I observed that Thread [DBus Sender Thread-1] sometimes inhibits the Java process from terminating cleanly.

There was a pending Connect call to a bluetooth device.

The code in org.freedesktop.dbus.connections.AbstractConnection.internalDisconnect(IOException) is intended to terminate such pending calls.

Unfortunately it is called with _connectionError == null on a regular disconnect. This leads to an NPE and the pending calls are not terminated so that in turn the sender thread is not terminated.

@hypfvieh
Copy link
Owner

Unfortunately it is called with _connectionError == null on a regular disconnect. This leads to an NPE and the pending calls are not terminated so that in turn the sender thread is not terminated.

Where?

When disconnect() or close() is called, the connection should be closed and all remaining calls should be answered or at least receive an Error. Therefore internalDisconnect() is called with null parameter to signal this is a ordered clean shutdown, no shutdown due to an DBus error.

So when bluetooth is hanging in some sort of timeout and your application quits, dbus-java tries it's best to signal that the requesting endpoint will disconnect now and that all remaining calls are canceled.

The only obvious annoyance here is that the ExecutorService for the Sending-Threadpool create non-daemon threads.
I will change that, there is no reason to use non-daemon threads and block anything.

@GeorgBisseling
Copy link
Author

The NPE is actually in the call new Error(mthCall, _connectionError) that is meant to be the reply to the pending call.

@hypfvieh
Copy link
Owner

That issue was already fixed in commit 814cf56 beginning of this year.
Please upgrade to 4.3.0

@GeorgBisseling
Copy link
Author

GeorgBisseling commented Sep 21, 2023

Ok, 4.3.x works for me.

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