[junit] avoid deadlock on runner retrieval (IDEA-297642)

GitOrigin-RevId: 07e44c38acb6d54ec60698e3fdab590e66148dbe
This commit is contained in:
Anna Kozlova
2022-07-08 14:04:20 +00:00
committed by intellij-monorepo-bot
parent 496550484c
commit 7d45076990
@@ -662,13 +662,16 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
}
private String myRunner;
private static final Object LOCK = ObjectUtils.sentinel("JUnitRunner");
@NotNull
protected synchronized String getRunner() {
if (myRunner == null) {
myRunner = ReadAction.nonBlocking(this::getRunnerInner).executeSynchronously();
protected String getRunner() {
synchronized (LOCK) {
if (myRunner == null) {
myRunner = ReadAction.nonBlocking(this::getRunnerInner).executeSynchronously();
}
return myRunner;
}
return myRunner;
}
@NotNull