Skip to content

Commit 6cda692

Browse files
committed
[grid] synchronize read from field written by other thread
1 parent 3ef121c commit 6cda692

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public HttpResponse addToQueue(SessionRequest request) {
216216
boolean sessionCreated = data.latch.await(requestTimeout.toMillis(), MILLISECONDS);
217217

218218
if (sessionCreated) {
219-
result = data.result;
219+
result = data.getResult();
220220
} else {
221221
result = Either.left(new SessionNotCreatedException("New session request timed out"));
222222
}
@@ -465,14 +465,18 @@ private class Data {
465465

466466
public final Instant endTime;
467467
private final CountDownLatch latch = new CountDownLatch(1);
468-
public Either<SessionNotCreatedException, CreateSessionResponse> result;
468+
private Either<SessionNotCreatedException, CreateSessionResponse> result;
469469
private boolean complete;
470470

471471
public Data(Instant enqueued) {
472472
this.endTime = enqueued.plus(requestTimeout);
473473
this.result = Either.left(new SessionNotCreatedException("Session not created"));
474474
}
475475

476+
public synchronized Either<SessionNotCreatedException, CreateSessionResponse> getResult() {
477+
return result;
478+
}
479+
476480
public synchronized void setResult(
477481
Either<SessionNotCreatedException, CreateSessionResponse> result) {
478482
if (complete) {

0 commit comments

Comments
 (0)