From 6cda69299366dd9e0976bede2fdbcfe42eb90cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sautter?= Date: Fri, 29 Mar 2024 20:59:13 +0100 Subject: [PATCH] [grid] synchronize read from field written by other thread --- .../grid/sessionqueue/local/LocalNewSessionQueue.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java b/java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java index d673cc342de95..9bad66db5b6f7 100644 --- a/java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java +++ b/java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java @@ -216,7 +216,7 @@ public HttpResponse addToQueue(SessionRequest request) { boolean sessionCreated = data.latch.await(requestTimeout.toMillis(), MILLISECONDS); if (sessionCreated) { - result = data.result; + result = data.getResult(); } else { result = Either.left(new SessionNotCreatedException("New session request timed out")); } @@ -465,7 +465,7 @@ private class Data { public final Instant endTime; private final CountDownLatch latch = new CountDownLatch(1); - public Either result; + private Either result; private boolean complete; public Data(Instant enqueued) { @@ -473,6 +473,10 @@ public Data(Instant enqueued) { this.result = Either.left(new SessionNotCreatedException("Session not created")); } + public synchronized Either getResult() { + return result; + } + public synchronized void setResult( Either result) { if (complete) {