Skip to content

Commit

Permalink
[java] Fixing double-check lock in a lazy initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Nov 10, 2020
1 parent 6e8bdcc commit d97844c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions java/server/src/org/openqa/selenium/grid/log/LoggingOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,17 @@ public Tracer getTracer() {

LOG.info("Using OpenTelemetry for tracing");

if (tracer != null) {
return tracer;
}

synchronized (LoggingOptions.class) {
if (tracer == null) {
tracer = createTracer();
Tracer localTracer = tracer;
if (localTracer == null) {
synchronized (LoggingOptions.class) {
localTracer = tracer;
if (localTracer == null) {
localTracer = createTracer();
tracer = localTracer;
}
}
}
return tracer;
return localTracer;
}

private Tracer createTracer() {
Expand Down

0 comments on commit d97844c

Please sign in to comment.