Skip to content

Commit c38c5fd

Browse files
s1ckknutwalker
andcommitted
Make ClockService.CLOCK access thread-safe
Co-Authored-By: Paul Horn <paul.horn@neotechnology.com>
1 parent 2734732 commit c38c5fd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core-utils/src/main/java/org/neo4j/gds/core/utils/ClockService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@
2020
package org.neo4j.gds.core.utils;
2121

2222
import java.time.Clock;
23+
import java.util.concurrent.atomic.AtomicReference;
2324

2425
public final class ClockService {
2526

2627
private static final Clock SYSTEM_CLOCK = Clock.systemUTC();
2728

28-
private static Clock CLOCK = SYSTEM_CLOCK;
29+
private static final AtomicReference<Clock> CLOCK = new AtomicReference<>(SYSTEM_CLOCK);
2930

3031
public static void setClock(Clock clock) {
31-
CLOCK = clock;
32+
CLOCK.set(clock);
3233
}
3334

3435
public static Clock clock() {
35-
return CLOCK;
36+
return CLOCK.get();
3637
}
3738

3839
private ClockService() {}

0 commit comments

Comments
 (0)