Skip to content

Conversation

Nadahar
Copy link
Contributor

@Nadahar Nadahar commented Sep 20, 2025

By using the discovery thread pool to do the actual registrations in AbstractDiscoveryService, binding threads won't have to wait for the registration to complete, which can be slow.

In addition, some thread-safety fixes have been done in AbstractDiscoveryService and DiscoveryServiceRegistryImpl, both to avoid contention and to ensure isolation of mutable objects.

This has emerged as an idea of mine after "investigating" several cases where OH gets very slow, stops working all together or crashes. Blocked threads with ever-increasing memory consumption as the thread pool queues grows because they are never processed, seems to be a common theme.

There are many reasons for the situation, this PR only addresses a little piece of the puzzle. But, I think it can make a real difference, because by using an executor to do the actual registration, we "break" the chain of locks/monitors being held. It no longer matters what locks the binding holds when thingDiscovered() is called, when the registration is done by the thread pool, it won't "inherit" any of the locks, and the rest of the system is free to move forward.

As everybody know, I assume, one of the "classic traps" in concurrency is to lock two locks/monitors in different order in different places of the code. Doing that practically ensures that you will have a deadlock, but it can be hard to avoid when parts of the system invokes other parts of the system in a complex way. The best way I've found to avoid this is to hold the locks as short as possible, and don't make calls into "unknown code" while holding locks, if at all avoidable. Invoking a listener method while holding a lock is a typical situation that has a high risk of causing a deadlock.

Even without a deadlock, the extreme slowness of the registration of discovery results can have cascading effects throughout the system. It would be interesting to find the reason for the slowness, and I hope that some of the "contention fixes" in this PR will help mitigate the problem. Regardless, an added bonus of isolating the locks by using the thread pool to do the registrations, is that this cascading effect is prevented.

Recently, when we worked on openhab/openhab-addons#17972, we had to make the Network binding spawn separate threads for registering the results to make the discovery operation smooth/fast. This PR will make that unnecessary, and it will benefit all bindings.

When I created openhab/openhab-addons#19351 a couple of days ago, it dawned on me that trying to chase this down on a binding-by-binding basis was the wrong approach.

Here is an excerpt from the thread dump from the associated forum thread (pay attention to lock 0x00000000814f9128):

"JmDNS pool-26-thread-1" #870 [2819882] prio=5 os_prio=0 cpu=2310,95ms elapsed=21361,57s tid=0x00007fbb35623170 nid=2819882 runnable  [0x00007fba20efc000]
   java.lang.Thread.State: RUNNABLE
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:493)
	at com.google.gson.Gson.toJson(Gson.java:944)
	at com.google.gson.Gson.toJsonTree(Gson.java:802)
	at com.google.gson.Gson.toJsonTree(Gson.java:779)
	at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.serialize(TreeTypeAdapter.java:189)
	at org.openhab.core.config.core.OrderingMapSerializer.lambda$0(OrderingMapSerializer.java:52)
	at org.openhab.core.config.core.OrderingMapSerializer$$Lambda/0x0000000100cf61e8.accept(Unknown Source)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(java.base@21.0.8/ForEachOps.java:184)
	at java.util.stream.SortedOps$RefSortingSink$$Lambda/0x00000001006ee168.accept(java.base@21.0.8/Unknown Source)
	at java.util.ArrayList.forEach(java.base@21.0.8/ArrayList.java:1596)
	at java.util.stream.SortedOps$RefSortingSink.end(java.base@21.0.8/SortedOps.java:395)
	at java.util.stream.AbstractPipeline.copyInto(java.base@21.0.8/AbstractPipeline.java:510)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(java.base@21.0.8/AbstractPipeline.java:499)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(java.base@21.0.8/ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(java.base@21.0.8/ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(java.base@21.0.8/AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEachOrdered(java.base@21.0.8/ReferencePipeline.java:601)
	at org.openhab.core.config.core.OrderingMapSerializer.serialize(OrderingMapSerializer.java:49)
	at org.openhab.core.config.core.OrderingMapSerializer.serialize(OrderingMapSerializer.java:1)
	at com.google.gson.internal.bind.TreeTypeAdapter.write(TreeTypeAdapter.java:108)
	at com.google.gson.internal.bind.TreeTypeAdapter.write(TreeTypeAdapter.java:101)
	at com.google.gson.Gson.toJson(Gson.java:944)
	at com.google.gson.Gson.toJson(Gson.java:899)
	at com.google.gson.Gson.toJson(Gson.java:848)
	at com.google.gson.Gson.toJson(Gson.java:825)
	at org.openhab.core.storage.json.internal.JsonStorage.flush(JsonStorage.java:352)
	- locked <0x00000000810e8820> (a org.openhab.core.storage.json.internal.JsonStorage)
	at org.openhab.core.storage.json.internal.JsonStorage.deferredCommit(JsonStorage.java:400)
	- locked <0x00000000810e8820> (a org.openhab.core.storage.json.internal.JsonStorage)
	at org.openhab.core.storage.json.internal.JsonStorage.put(JsonStorage.java:168)
	at org.openhab.core.common.registry.AbstractManagedProvider.update(AbstractManagedProvider.java:109)
	at org.openhab.core.config.discovery.internal.PersistentInbox.internalAdd(PersistentInbox.java:305)
	at org.openhab.core.config.discovery.internal.PersistentInbox.add(PersistentInbox.java:237)
	- locked <0x000000008514ce30> (a org.openhab.core.config.discovery.internal.PersistentInbox)
	at org.openhab.core.config.discovery.internal.PersistentInbox.thingDiscovered(PersistentInbox.java:402)
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.thingDiscovered(DiscoveryServiceRegistryImpl.java:262)
	- locked <0x00000000814f9128> (a org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl)
	at org.openhab.core.config.discovery.AbstractDiscoveryService.thingDiscovered(AbstractDiscoveryService.java:318)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.createDiscoveryResult(MDNSDiscoveryService.java:227)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.considerService(MDNSDiscoveryService.java:214)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.serviceResolved(MDNSDiscoveryService.java:207)
	at javax.jmdns.impl.ListenerStatus$ServiceListenerStatus.serviceResolved(ListenerStatus.java:117)
	- locked <0x00000000e096ed10> (a javax.jmdns.impl.ListenerStatus$ServiceListenerStatus)
	at javax.jmdns.impl.JmDNSImpl$1.run(JmDNSImpl.java:923)
	at java.util.concurrent.Executors$RunnableAdapter.call(java.base@21.0.8/Executors.java:572)
	at java.util.concurrent.FutureTask.run(java.base@21.0.8/FutureTask.java:317)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@21.0.8/ThreadPoolExecutor.java:1144)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@21.0.8/ThreadPoolExecutor.java:642)
	at java.lang.Thread.runWith(java.base@21.0.8/Thread.java:1596)
	at java.lang.Thread.run(java.base@21.0.8/Thread.java:1583)

"JmDNS pool-27-thread-1" #871 [2819883] prio=5 os_prio=0 cpu=2478,52ms elapsed=21361,56s tid=0x00007fbb35624bf0 nid=2819883 waiting for monitor entry  [0x00007fba205fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.thingDiscovered(DiscoveryServiceRegistryImpl.java:257)
	- waiting to lock <0x00000000814f9128> (a org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl)
	at org.openhab.core.config.discovery.AbstractDiscoveryService.thingDiscovered(AbstractDiscoveryService.java:318)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.createDiscoveryResult(MDNSDiscoveryService.java:227)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.considerService(MDNSDiscoveryService.java:214)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.serviceResolved(MDNSDiscoveryService.java:207)
	at javax.jmdns.impl.ListenerStatus$ServiceListenerStatus.serviceResolved(ListenerStatus.java:117)
	- locked <0x00000000911c3db0> (a javax.jmdns.impl.ListenerStatus$ServiceListenerStatus)
	at javax.jmdns.impl.JmDNSImpl$1.run(JmDNSImpl.java:923)
	at java.util.concurrent.Executors$RunnableAdapter.call(java.base@21.0.8/Executors.java:572)
	at java.util.concurrent.FutureTask.run(java.base@21.0.8/FutureTask.java:317)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@21.0.8/ThreadPoolExecutor.java:1144)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@21.0.8/ThreadPoolExecutor.java:642)
	at java.lang.Thread.runWith(java.base@21.0.8/Thread.java:1596)
	at java.lang.Thread.run(java.base@21.0.8/Thread.java:1583)

"JmDNS pool-28-thread-1" #872 [2819884] prio=5 os_prio=0 cpu=2226,44ms elapsed=21361,56s tid=0x00007fbb356244a0 nid=2819884 waiting for monitor entry  [0x00007fba204fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.thingDiscovered(DiscoveryServiceRegistryImpl.java:257)
	- waiting to lock <0x00000000814f9128> (a org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl)
	at org.openhab.core.config.discovery.AbstractDiscoveryService.thingDiscovered(AbstractDiscoveryService.java:318)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.createDiscoveryResult(MDNSDiscoveryService.java:227)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.considerService(MDNSDiscoveryService.java:214)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.serviceResolved(MDNSDiscoveryService.java:207)
	at javax.jmdns.impl.ListenerStatus$ServiceListenerStatus.serviceResolved(ListenerStatus.java:117)
	- locked <0x000000009119c2e0> (a javax.jmdns.impl.ListenerStatus$ServiceListenerStatus)
	at javax.jmdns.impl.JmDNSImpl$1.run(JmDNSImpl.java:923)
	at java.util.concurrent.Executors$RunnableAdapter.call(java.base@21.0.8/Executors.java:572)
	at java.util.concurrent.FutureTask.run(java.base@21.0.8/FutureTask.java:317)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@21.0.8/ThreadPoolExecutor.java:1144)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@21.0.8/ThreadPoolExecutor.java:642)
	at java.lang.Thread.runWith(java.base@21.0.8/Thread.java:1596)
	at java.lang.Thread.run(java.base@21.0.8/Thread.java:1583)

"JmDNS pool-30-thread-1" #874 [2819886] prio=5 os_prio=0 cpu=2401,91ms elapsed=21361,54s tid=0x00007fbb35626f10 nid=2819886 waiting for monitor entry  [0x00007fba202fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.thingDiscovered(DiscoveryServiceRegistryImpl.java:257)
	- waiting to lock <0x00000000814f9128> (a org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl)
	at org.openhab.core.config.discovery.AbstractDiscoveryService.thingDiscovered(AbstractDiscoveryService.java:318)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.createDiscoveryResult(MDNSDiscoveryService.java:227)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.considerService(MDNSDiscoveryService.java:214)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.serviceResolved(MDNSDiscoveryService.java:207)
	at javax.jmdns.impl.ListenerStatus$ServiceListenerStatus.serviceResolved(ListenerStatus.java:117)
	- locked <0x000000008d346d28> (a javax.jmdns.impl.ListenerStatus$ServiceListenerStatus)
	at javax.jmdns.impl.JmDNSImpl$1.run(JmDNSImpl.java:923)
	at java.util.concurrent.Executors$RunnableAdapter.call(java.base@21.0.8/Executors.java:572)
	at java.util.concurrent.FutureTask.run(java.base@21.0.8/FutureTask.java:317)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@21.0.8/ThreadPoolExecutor.java:1144)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@21.0.8/ThreadPoolExecutor.java:642)
	at java.lang.Thread.runWith(java.base@21.0.8/Thread.java:1596)
	at java.lang.Thread.run(java.base@21.0.8/Thread.java:1583)

"JmDNS pool-32-thread-1" #876 [2819889] prio=5 os_prio=0 cpu=2249,22ms elapsed=21361,53s tid=0x00007fbb35629990 nid=2819889 waiting for monitor entry  [0x00007fba200fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.thingDiscovered(DiscoveryServiceRegistryImpl.java:257)
	- waiting to lock <0x00000000814f9128> (a org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl)
	at org.openhab.core.config.discovery.AbstractDiscoveryService.thingDiscovered(AbstractDiscoveryService.java:318)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.createDiscoveryResult(MDNSDiscoveryService.java:227)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.considerService(MDNSDiscoveryService.java:214)
	at org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService.serviceResolved(MDNSDiscoveryService.java:207)
	at javax.jmdns.impl.ListenerStatus$ServiceListenerStatus.serviceResolved(ListenerStatus.java:117)
	- locked <0x000000008d7afcd0> (a javax.jmdns.impl.ListenerStatus$ServiceListenerStatus)
	at javax.jmdns.impl.JmDNSImpl$1.run(JmDNSImpl.java:923)
	at java.util.concurrent.Executors$RunnableAdapter.call(java.base@21.0.8/Executors.java:572)
	at java.util.concurrent.FutureTask.run(java.base@21.0.8/FutureTask.java:317)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@21.0.8/ThreadPoolExecutor.java:1144)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@21.0.8/ThreadPoolExecutor.java:642)
	at java.lang.Thread.runWith(java.base@21.0.8/Thread.java:1596)
	at java.lang.Thread.run(java.base@21.0.8/Thread.java:1583)

"OH-binding-teleinfo:serialcontroller:teleinfoserial" #1165 [2820248] daemon prio=5 os_prio=0 cpu=9998,65ms elapsed=21349,28s tid=0x00007fbb0c114430 nid=2820248 waiting for monitor entry  [0x00007fba1b8fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.thingDiscovered(DiscoveryServiceRegistryImpl.java:257)
	- waiting to lock <0x00000000814f9128> (a org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl)
	at org.openhab.core.config.discovery.AbstractDiscoveryService.thingDiscovered(AbstractDiscoveryService.java:318)
	at org.openhab.binding.teleinfo.internal.TeleinfoDiscoveryService.detectNewElectricityMeterFromReceivedFrame(TeleinfoDiscoveryService.java:132)
	at org.openhab.binding.teleinfo.internal.TeleinfoDiscoveryService.onFrameReceived(TeleinfoDiscoveryService.java:111)
	at org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler.lambda$0(TeleinfoAbstractControllerHandler.java:49)
	at org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler$$Lambda/0x0000000101341188.accept(Unknown Source)
	at java.util.concurrent.CopyOnWriteArrayList.forEach(java.base@21.0.8/CopyOnWriteArrayList.java:891)
	at java.util.concurrent.CopyOnWriteArraySet.forEach(java.base@21.0.8/CopyOnWriteArraySet.java:425)
	at org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractControllerHandler.fireOnFrameReceivedEvent(TeleinfoAbstractControllerHandler.java:49)
	at org.openhab.binding.teleinfo.internal.serial.TeleinfoSerialControllerHandler.onFrameReceived(TeleinfoSerialControllerHandler.java:108)
	at org.openhab.binding.teleinfo.internal.serial.TeleinfoReceiveThread.run(TeleinfoReceiveThread.java:63)

For all mDNS discoveries, the JmDNS threads will be he ones performing the actual "discovery process", because they are the ones the executes the listener method. In the above case, JmDNS pool-26-thread-1 is busy deep inside Gson doing something that I assume takes a long time, or is held up by something else. In the meanwhile, 4 other JmDNS threads and the Teleinfo binding discovery thread are blocked waiting for JmDNS pool-26-thread-1 to finish. I don't know how big the JmDNS thread pool is, but this could potentially exchaust the thread pool. For Teleinfo, the thread name OH-binding-teleinfo:serialcontroller:teleinfoserial hints that this is the sole thread responsible for communication with the serial controller that is being blocked.

By isolating the discovery result registration from the rest of the system, we will no longer have situations like this.

@Nadahar Nadahar requested a review from a team as a code owner September 20, 2025 02:38
@wborn wborn requested a review from Copilot September 20, 2025 08:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves concurrency and thread safety in the OpenHab discovery system by isolating discovery result registrations from binding threads and addressing thread contention issues in AbstractDiscoveryService and DiscoveryServiceRegistryImpl. The primary goal is to prevent thread starvation and deadlocks that occur when binding threads are blocked waiting for slow discovery registrations.

  • Discovery result registrations are now executed asynchronously using the discovery thread pool instead of blocking binding threads
  • Thread safety improvements include better synchronization patterns and reduced lock contention
  • Collection type changes to thread-safe alternatives to prevent concurrent modification issues

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
DiscoveryServiceRegistryImpl.java Removes unnecessary synchronized methods, changes to thread-safe collections, and improves synchronization patterns to reduce contention
AbstractDiscoveryService.java Adds asynchronous execution of discovery listener notifications and improves thread safety with better synchronization of mutable state

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

By using the discovery thread pool to do the actual registrations in AbstractDiscoveryService, binding threads won't have to wait for the registration to complete, which can be slow.

In addition, some thread-safety fixes have been done in AbstractDiscoveryService and DiscoveryServiceRegistryImpl, both to avoid contention and to ensure isolation of mutable objects.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
@Nadahar Nadahar force-pushed the discovery-registration-isolation branch from 459f33c to c78ccda Compare September 20, 2025 19:00
@Nadahar
Copy link
Contributor Author

Nadahar commented Sep 20, 2025

I pushed a rebase to latest main after #5020 was merged, no changes were done to the code in this PR, so the above Copilot review comments "still apply". I don't think they should be acted on though, but leave them up in case others see it differently.

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for diving into this and for your detailed explanations!

I must admit, I cannot assess the impact of all the small changes that you did here, but it's likely a good moment to have this merged and find out if there are any corner cases where we might have regressions.

@kaikreuzer kaikreuzer merged commit aa73ac8 into openhab:main Oct 10, 2025
4 checks passed
@kaikreuzer kaikreuzer added the enhancement An enhancement or new feature of the Core label Oct 10, 2025
@kaikreuzer kaikreuzer added this to the 5.1 milestone Oct 10, 2025
@jlaur
Copy link
Contributor

jlaur commented Oct 11, 2025

@Nadahar - some tests in addons are failing today - see https://ci.openhab.org/job/openHAB-Addons/1928/. It seems they are all related to discovery, so perhaps you could help figuring out why? One example: https://github.com/openhab/openhab-addons/blob/main/bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java:

[ERROR] Failures: 
[ERROR]   ThingDiscoveryServiceTest.testAddDevice:188 
Wanted but not invoked:
discoveryListener.thingDiscovered(
    <Capturing argument: DiscoveryService>,
    <Capturing argument: DiscoveryResult>
);
-> at org.openhab.binding.boschshc.internal.discovery.ThingDiscoveryServiceTest.testAddDevice(ThingDiscoveryServiceTest.java:188)
Actually, there were zero interactions with this mock.

@Nadahar
Copy link
Contributor Author

Nadahar commented Oct 11, 2025

@jlaur Let's see how much is resolved now that I've rebased openhab/openhab-addons#19230 before I start looking into the details.

@Nadahar
Copy link
Contributor Author

Nadahar commented Oct 11, 2025

@jlaur I'm looking at org.openhab.binding.boschshc now, and that test failure is definitely related to this PR. The test wants to verify the discovery result, but it's no longer registered because the registration is now done async.

This mocking really isn't my strong suite, but I'll try to figure out something. Anybody else that have some hints as to how to address that are very welcome to chime in.

I guess it could either be that the threads doing the registration don't exist because of the mock, or it could be that they do run, but that the results aren't in immediately after method return, as the test expects.

@Nadahar
Copy link
Contributor Author

Nadahar commented Oct 11, 2025

I've fixed org.openhab.binding.boschshc - the registration thread was running, but the result wasn't available immediately on method return, so I just had to add a timeout value to the result capture. I've look at the others, I assume that the problem is similar.

Nadahar pushed a commit to Nadahar/openhab-addons that referenced this pull request Oct 11, 2025
openhab/openhab-core#5032 made discovery result registration asynchronous, which led to some tests failing because the discovery results aren't immediately available one the call to thingDiscovered() returns - because the registration itself is done in a different thread. This has been addressed by pausing slightly before testing the results.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Nadahar pushed a commit to Nadahar/openhab-addons that referenced this pull request Oct 11, 2025
openhab/openhab-core#5032 made discovery result registration asynchronous, which led to some tests failing because the discovery results aren't immediately available one the call to thingDiscovered() returns - because the registration itself is done in a different thread. This has been addressed by pausing slightly before testing the results.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Nadahar pushed a commit to Nadahar/openhab-addons that referenced this pull request Oct 11, 2025
openhab/openhab-core#5032 made discovery result registration asynchronous, which led to some tests failing because the discovery results aren't immediately available one the call to thingDiscovered() returns - because the registration itself is done in a different thread. This has been addressed by pausing slightly before testing the results.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
jlaur pushed a commit to openhab/openhab-addons that referenced this pull request Oct 11, 2025
openhab/openhab-core#5032 made discovery result registration asynchronous, which led to some tests failing because the discovery results aren't immediately available one the call to thingDiscovered() returns - because the registration itself is done in a different thread. This has been addressed by pausing slightly before testing the results.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Nadahar pushed a commit to Nadahar/openhab-addons that referenced this pull request Oct 12, 2025
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Nadahar pushed a commit to Nadahar/openhab-addons that referenced this pull request Oct 12, 2025
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
@Nadahar Nadahar deleted the discovery-registration-isolation branch October 12, 2025 18:28
jlaur pushed a commit to openhab/openhab-addons that referenced this pull request Oct 12, 2025
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
@Nadahar Nadahar mentioned this pull request Oct 13, 2025
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/openhab-5-1-milestone-discussion/166385/55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature of the Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants