Skip to content

Commit 57610c1

Browse files
dependabot[bot]belaban
authored andcommitted
Bump org.apache.logging.log4j:log4j-core from 2.26.0 to 2.26.1
Bumps org.apache.logging.log4j:log4j-core from 2.26.0 to 2.26.1. --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-core dependency-version: 2.26.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> - Runner stop deadlock - Runner.stop and run methods compete for the same intrinsic lock when stopping. - Added RunnerTest.testStop2(): https://redhat.atlassian.net/browse/JGRP-3020
1 parent 08e4438 commit 57610c1

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/org/jgroups/util/Runner.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,15 @@ public synchronized Runner start() {
6161
return this;
6262
}
6363

64-
public synchronized Runner stop() {
65-
boolean rc=state(State.stopping);
66-
if(!rc)
67-
return this;
68-
Thread tmp=thread;
64+
public Runner stop() {
65+
Thread tmp;
66+
synchronized (this) {
67+
boolean rc=state(State.stopping);
68+
if(!rc)
69+
return this;
70+
tmp=thread;
71+
}
72+
6973
if(tmp != null) {
7074
tmp.interrupt();
7175
if(join_timeout > 0) {

tests/junit-functional/org/jgroups/tests/RunnerTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ public void testStop() throws TimeoutException {
8181
Util.waitUntil(5000, 100, () -> runner.state() == stopped);
8282
}
8383

84+
/** Tests https://redhat.atlassian.net/browse/JGRP-3020 */
85+
public void testStop2() throws TimeoutException {
86+
final long timeout=3000;
87+
Runnable fun=() -> Util.sleep(100);
88+
runner=createRunner(fun, null)
89+
.setJoinTimeout(timeout)
90+
.start();
91+
Util.waitUntil(2000, 100, () -> runner.state() == running);
92+
long start=System.nanoTime();
93+
runner.stop(); // will block without https://redhat.atlassian.net/browse/JGRP-3020 for join_timeout ms
94+
long time=System.nanoTime() - start;
95+
long millis=TimeUnit.NANOSECONDS.toMillis(time);
96+
assert millis < 300 // sleep 100ms
97+
: String.format("expected to block in stop() less than 300 ms, but blocked for %s", Util.printTime(time));
98+
System.out.printf("stop() blocked for %s\n", Util.printTime(time));
99+
}
100+
84101
/**
85102
* Tests the ABA problem (https://issues.redhat.com/browse/JGRP-2919)
86103
*/

0 commit comments

Comments
 (0)