Skip to content

Commit 98aead0

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Also, suppress https://errorprone.info/bugpattern/ThreadPriorityCheck in `ThreadFactoryBuilderTest`. RELNOTES=n/a PiperOrigin-RevId: 850082699
1 parent d8aef62 commit 98aead0

File tree

25 files changed

+384
-118
lines changed

25 files changed

+384
-118
lines changed

android/guava-testlib/src/com/google/common/collect/testing/Platform.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.collect.testing;
1818

1919
import com.google.common.annotations.GwtCompatible;
20+
import com.google.errorprone.annotations.FormatMethod;
2021
import java.util.Locale;
2122

2223
/**
@@ -37,6 +38,7 @@ static void checkCast(Class<?> clazz, Object obj) {
3738
Object unused = clazz.cast(obj);
3839
}
3940

41+
@FormatMethod
4042
static String format(String template, Object... args) {
4143
return String.format(Locale.ROOT, template, args);
4244
}

android/guava-testlib/src/com/google/common/collect/testing/testers/Platform.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.collect.testing.testers;
1818

1919
import com.google.common.annotations.GwtCompatible;
20+
import com.google.errorprone.annotations.FormatMethod;
2021
import java.util.Locale;
2122

2223
/**
@@ -28,6 +29,7 @@
2829
final class Platform {
2930

3031
/** Format the template with args, only supports the placeholder {@code %s}. */
32+
@FormatMethod
3133
static String format(String template, Object... args) {
3234
return String.format(Locale.ROOT, template, args);
3335
}

android/guava-testlib/src/com/google/common/testing/GcFinalization.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.common.annotations.GwtIncompatible;
2323
import com.google.common.annotations.J2ktIncompatible;
2424
import com.google.errorprone.annotations.DoNotMock;
25+
import com.google.errorprone.annotations.FormatMethod;
2526
import com.google.j2objc.annotations.J2ObjCIncompatible;
2627
import java.lang.ref.WeakReference;
2728
import java.util.Locale;
@@ -316,6 +317,7 @@ protected void finalize() {
316317
System.runFinalization();
317318
}
318319

320+
@FormatMethod
319321
private static RuntimeException formatRuntimeException(String format, Object... args) {
320322
return new RuntimeException(String.format(Locale.ROOT, format, args));
321323
}

android/guava-tests/test/com/google/common/collect/FauxveridesTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import com.google.common.base.Function;
2727
import com.google.common.base.Joiner;
28+
import com.google.errorprone.annotations.FormatMethod;
2829
import java.lang.reflect.Method;
2930
import java.lang.reflect.Type;
3031
import java.lang.reflect.TypeVariable;
@@ -289,6 +290,7 @@ public String apply(Type from) {
289290
}
290291
};
291292

293+
@FormatMethod
292294
private static String rootLocaleFormat(String format, Object... args) {
293295
return String.format(Locale.ROOT, format, args);
294296
}

android/guava-tests/test/com/google/common/math/DoubleUtilsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static com.google.common.truth.Truth.assertThat;
2323
import static org.junit.Assert.assertThrows;
2424

25+
import com.google.errorprone.annotations.FormatMethod;
2526
import java.lang.reflect.Method;
2627
import java.math.BigInteger;
2728
import junit.framework.TestCase;
@@ -76,6 +77,7 @@ public void testOneBits() {
7677
assertEquals(DoubleUtils.ONE_BITS, Double.doubleToRawLongBits(1.0));
7778
}
7879

80+
@FormatMethod
7981
private static void failFormat(String template, Object... args) {
8082
fail(String.format(template, args));
8183
}

android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.junit.Assert.assertThrows;
2222

2323
import com.google.common.testing.NullPointerTester;
24+
import com.google.errorprone.annotations.FormatMethod;
2425
import java.lang.Thread.UncaughtExceptionHandler;
2526
import java.util.Locale;
2627
import java.util.concurrent.ThreadFactory;
@@ -180,6 +181,8 @@ public void testThreadFactory() throws InterruptedException {
180181
boolean THREAD_DAEMON = false;
181182
ThreadFactory backingThreadFactory =
182183
new ThreadFactory() {
184+
// We need to test that we don't override the value set by the factory.
185+
@SuppressWarnings("ThreadPriorityCheck")
183186
@Override
184187
public Thread newThread(Runnable r) {
185188
Thread thread = new Thread(r);
@@ -213,6 +216,7 @@ public void testNulls() {
213216
npTester.testAllPublicInstanceMethods(builder);
214217
}
215218

219+
@FormatMethod
216220
private static String rootLocaleFormat(String format, Object... args) {
217221
return String.format(Locale.ROOT, format, args);
218222
}

android/guava/src/com/google/common/base/Platform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ static String nullToEmpty(@Nullable String string) {
7878
return stringIsNullOrEmpty(string) ? null : string;
7979
}
8080

81-
static String lenientFormat(@Nullable String template, @Nullable Object @Nullable ... args) {
81+
static String lenientFormat(
82+
@Nullable String template, @Nullable Object @Nullable ... args) {
8283
return Strings.lenientFormat(template, args);
8384
}
8485

0 commit comments

Comments
 (0)