diff --git a/java/server/src/org/openqa/selenium/grid/log/LoggingOptions.java b/java/server/src/org/openqa/selenium/grid/log/LoggingOptions.java index a3a8eeab161de..8f11d49ac8f60 100644 --- a/java/server/src/org/openqa/selenium/grid/log/LoggingOptions.java +++ b/java/server/src/org/openqa/selenium/grid/log/LoggingOptions.java @@ -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() {