openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

[bluetooth.bluez] NPE when adapter disappears #13357

Closed seime closed 1 year ago

seime commented 2 years ago

Setup: PI 4b, no local Bluetooth dongle but connected via usbip.

This happens when the USB-adapter disappers (lsusb does no longer report it) on the openhab side (due to usbip stops working). The binding remains in this state even if adapter is reconnected, and continues to spit out these exceptions every 10s.

Expected behaviour:

Restarting openHAB solves the problem (not necessary to restart os bluetooth.service)

Tried to update bluez-dbus-osgi to 0.1.4 without success.

2022-09-05 10:09:37.762 [WARN ] [th.bluez.internal.BlueZBridgeHandler] - Unknown exception
java.lang.NullPointerException: null
        at com.github.hypfvieh.bluetooth.wrapper.BluetoothAdapter.isPowered(BluetoothAdapter.java:100) ~[?:?]
        at org.openhab.binding.bluetooth.bluez.internal.BlueZBridgeHandler.prepareAdapter(BlueZBridgeHandler.java:134) ~[?:?]
        at org.openhab.binding.bluetooth.bluez.internal.BlueZBridgeHandler.initializeAndRefreshDevices(BlueZBridgeHandler.java:162) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]
lsiepel commented 1 year ago

@seime Can you verify if this issue still happens with the latest 4.0.0 snapshot? As i'm working on improving the bluetooth bindings by adding null annotations i suspect it was allready fixed.

If not i'll try to come up with a solution. At that point it would be helpfull if you set the binding at log leverl debug.

seime commented 1 year ago

I no longer have this setup as usbip was too flaky, but maybe it is possible to reproduce it by simply disconnecting the bluetooth usb adapter?

lsiepel commented 1 year ago

I don't own this device, so i can't reproduce it. And you don't have this setup anymore, so i think we better close this issue and re-open whenever there is a need to.