Skip to content

Commit

Permalink
Mark java.time.InstantSource and java.time.Clock as thread safe.
Browse files Browse the repository at this point in the history
Also, annotate `FakeTimeSource` with `@ThreadSafe` to fix breakages caused by marking `InstantSource` as thread safe. `TimeSource` and `common.time.Clock` should also be annotated directly, but we would need to fix or suppress all existing implementations of them first, so I left a TODO instead.

Context: http://yaqs/6914049073339170816

Tested:
    TAP for global presubmit queue
    []
PiperOrigin-RevId: 705936781
  • Loading branch information
chaoren authored and Error Prone Team committed Dec 13, 2024
1 parent 9a9681a commit 83634a5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ private static ImmutableMap<String, AnnotationInfo> buildThreadSafeClasses(
new MapBuilder()
.addAll(mutability.getKnownImmutableClasses())
.addStrings(extraKnownThreadSafe)
.add(ClassLoader.class)
.add(Thread.class)
.add(java.lang.ClassLoader.class)
.add(java.lang.Thread.class)
.add(java.time.InstantSource.class)
.add(java.time.Clock.class)
.add(java.util.Random.class)
.add(java.util.concurrent.atomic.AtomicBoolean.class)
.add(java.util.concurrent.atomic.AtomicInteger.class)
Expand Down Expand Up @@ -108,8 +110,6 @@ private static ImmutableMap<String, AnnotationInfo> buildThreadSafeClasses(
.add(java.security.SecureRandom.class)
.add("com.google.common.base.Ticker")
.add("com.google.common.testing.FakeTicker")
.add("com.google.common.time.Clock")
.add("com.google.common.time.TimeSource")
.add("com.google.common.util.concurrent.AtomicLongMap", "K")
.add("com.google.common.util.concurrent.CheckedFuture", "V", "X")
.add("com.google.common.util.concurrent.ListeningExecutorService")
Expand Down

0 comments on commit 83634a5

Please sign in to comment.