This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/main by this push:
new e1382c51f3b CAUSEWAY-3972: fixes test in prev. commit
e1382c51f3b is described below
commit e1382c51f3b589e7370e8cc8e5f3841de691a9ac
Author: andi-huber <[email protected]>
AuthorDate: Wed Mar 4 17:13:39 2026 +0100
CAUSEWAY-3972: fixes test in prev. commit
---
.../apache/causeway/commons/internal/base/_OneshotTest.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git
a/commons/src/test/java/org/apache/causeway/commons/internal/base/_OneshotTest.java
b/commons/src/test/java/org/apache/causeway/commons/internal/base/_OneshotTest.java
index a5ef79e95d3..baad496f020 100644
---
a/commons/src/test/java/org/apache/causeway/commons/internal/base/_OneshotTest.java
+++
b/commons/src/test/java/org/apache/causeway/commons/internal/base/_OneshotTest.java
@@ -18,10 +18,12 @@
*/
package org.apache.causeway.commons.internal.base;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.LongAdder;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import lombok.SneakyThrows;
@@ -30,23 +32,27 @@ class _OneshotTest {
final _Oneshot oneshot = new _Oneshot();
final LongAdder counter = new LongAdder();
+ final AtomicReference<String> errors = new AtomicReference<>();
@Test
void test() {
oneshot.trigger(this::sayHelloOnce);
+ assertEquals(1, counter.intValue());
+ assertEquals(null, errors.get());
}
@SneakyThrows
void sayHelloOnce() {
if(counter.intValue()>0) {
+ errors.set("recursion detected");
fail("recursion detected");
}
counter.increment();
// calling 'sayHelloOnce' from a different thread, while still
executing in the main thread,
- // must not lead to a recursions
- var thread = new Thread(this::sayHelloOnce);
+ // must not lead to a recursion
+ var thread = new Thread(()->oneshot.trigger(this::sayHelloOnce));
thread.start();
thread.join();
}