From 15a12a1f7d2153ea29989131f84c28d057858b63 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 9 Jul 2024 11:59:15 +0200 Subject: [PATCH] [Fix] Fixed broken tests --- .../li/strolch/utils/concurrent/ElementLockingHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/src/main/java/li/strolch/utils/concurrent/ElementLockingHandler.java b/utils/src/main/java/li/strolch/utils/concurrent/ElementLockingHandler.java index 18f8ceb35..cc59be6a4 100644 --- a/utils/src/main/java/li/strolch/utils/concurrent/ElementLockingHandler.java +++ b/utils/src/main/java/li/strolch/utils/concurrent/ElementLockingHandler.java @@ -51,8 +51,10 @@ public void lockedExecute(T element, CheckedRunnable action) { try { action.run(); } catch (Exception e) { + if (e instanceof RuntimeException re) + throw re; String msg = format("Failed to execute action {0} for locked element {1}", action, element); - throw new ElementLockingException(msg, e); + throw new IllegalStateException(msg, e); } finally { unlock(element); } @@ -75,6 +77,8 @@ public U lockedExecuteWithResult(T element, CheckedSupplier action) { try { return action.get(); } catch (Exception e) { + if (e instanceof RuntimeException re) + throw re; String msg = format("Failed to execute action {0} for locked element {1}", action, element); throw new IllegalStateException(msg, e); } finally {