From 554495b89fb5c45c2edaa05b103e99e3b0de9963 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 26 Oct 2024 14:10:05 +0200 Subject: [PATCH] [jsscripting] Remove Thread.sleep workaround for multi-threading issues with UI-based scripts Follow-up for #1710. Depends on https://github.com/openhab/openhab-core/pull/4426. Signed-off-by: Florian Hotze --- .../internal/OpenhabGraalJSScriptEngine.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/bundles/org.openhab.automation.jsscripting/src/main/java/org/openhab/automation/jsscripting/internal/OpenhabGraalJSScriptEngine.java b/bundles/org.openhab.automation.jsscripting/src/main/java/org/openhab/automation/jsscripting/internal/OpenhabGraalJSScriptEngine.java index 5cca25dccde4c..b842b3bb0ce41 100644 --- a/bundles/org.openhab.automation.jsscripting/src/main/java/org/openhab/automation/jsscripting/internal/OpenhabGraalJSScriptEngine.java +++ b/bundles/org.openhab.automation.jsscripting/src/main/java/org/openhab/automation/jsscripting/internal/OpenhabGraalJSScriptEngine.java @@ -304,13 +304,6 @@ protected void beforeInvocation() { protected Object afterInvocation(Object obj) { lock.unlock(); logger.debug("Lock released after invocation."); - // Fixes illegal multi-thread access requested in UI-based scripts, where the script is running and a timer is - // waiting to acquire the lock. - try { - Thread.sleep(10); - } catch (InterruptedException e) { - throw new RuntimeException("Thread interrupted while sleeping", e); - } return super.afterInvocation(obj); } @@ -385,13 +378,6 @@ public boolean tryLock(long l, TimeUnit timeUnit) throws InterruptedException { public void unlock() { lock.unlock(); logger.debug("Lock released."); - // Fixes illegal multi-thread access requested in UI-based scripts, where the script is running and a timer is - // waiting to acquire the lock. - try { - Thread.sleep(10); - } catch (InterruptedException e) { - throw new RuntimeException("Thread interrupted while sleeping", e); - } } @Override