From 5d6e2bd640da6eed40422bdf25e0f40fbf7e601a Mon Sep 17 00:00:00 2001 From: cpovirk Date: Wed, 4 Dec 2024 11:30:42 -0800 Subject: [PATCH] Suppress https://errorprone.info/bugpattern/ThrowIfUncheckedKnownUnchecked warnings. RELNOTES=n/a PiperOrigin-RevId: 702798888 --- .../test/com/google/common/base/ThrowablesTest.java | 10 ++++++++++ .../test/com/google/common/base/ThrowablesTest.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/android/guava-tests/test/com/google/common/base/ThrowablesTest.java b/android/guava-tests/test/com/google/common/base/ThrowablesTest.java index 78fd4affa5d4..c8a6765a1077 100644 --- a/android/guava-tests/test/com/google/common/base/ThrowablesTest.java +++ b/android/guava-tests/test/com/google/common/base/ThrowablesTest.java @@ -55,11 +55,15 @@ @GwtCompatible(emulated = true) @SuppressWarnings("deprecation") // tests of numerous deprecated methods public class ThrowablesTest extends TestCase { + // We're testing that the method is in fact equivalent to throwing the exception directly. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testThrowIfUnchecked_unchecked() { assertThrows( SomeUncheckedException.class, () -> throwIfUnchecked(new SomeUncheckedException())); } + // We're testing that the method is in fact equivalent to throwing the exception directly. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testThrowIfUnchecked_error() { assertThrows(SomeError.class, () -> throwIfUnchecked(new SomeError())); } @@ -71,6 +75,8 @@ public void testThrowIfUnchecked_checked() { @J2ktIncompatible @GwtIncompatible // propagateIfPossible + // We're testing that the method is in fact equivalent to throwing the exception directly. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testPropagateIfPossible_noneDeclared_unchecked() { assertThrows( SomeUncheckedException.class, () -> propagateIfPossible(new SomeUncheckedException())); @@ -151,12 +157,16 @@ public void testPropagateIfPossible_twoDeclared_neitherSame() SomeOtherCheckedException.class); } + // I guess it's technically a bug that ThrowIfUncheckedKnownUnchecked fires here. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testThrowIfUnchecked_null() { assertThrows(NullPointerException.class, () -> throwIfUnchecked(null)); } @J2ktIncompatible @GwtIncompatible // propagateIfPossible + // I guess it's technically a bug that ThrowIfUncheckedKnownUnchecked fires here. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testPropageIfPossible_null() { propagateIfPossible(null); } diff --git a/guava-tests/test/com/google/common/base/ThrowablesTest.java b/guava-tests/test/com/google/common/base/ThrowablesTest.java index 78fd4affa5d4..c8a6765a1077 100644 --- a/guava-tests/test/com/google/common/base/ThrowablesTest.java +++ b/guava-tests/test/com/google/common/base/ThrowablesTest.java @@ -55,11 +55,15 @@ @GwtCompatible(emulated = true) @SuppressWarnings("deprecation") // tests of numerous deprecated methods public class ThrowablesTest extends TestCase { + // We're testing that the method is in fact equivalent to throwing the exception directly. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testThrowIfUnchecked_unchecked() { assertThrows( SomeUncheckedException.class, () -> throwIfUnchecked(new SomeUncheckedException())); } + // We're testing that the method is in fact equivalent to throwing the exception directly. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testThrowIfUnchecked_error() { assertThrows(SomeError.class, () -> throwIfUnchecked(new SomeError())); } @@ -71,6 +75,8 @@ public void testThrowIfUnchecked_checked() { @J2ktIncompatible @GwtIncompatible // propagateIfPossible + // We're testing that the method is in fact equivalent to throwing the exception directly. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testPropagateIfPossible_noneDeclared_unchecked() { assertThrows( SomeUncheckedException.class, () -> propagateIfPossible(new SomeUncheckedException())); @@ -151,12 +157,16 @@ public void testPropagateIfPossible_twoDeclared_neitherSame() SomeOtherCheckedException.class); } + // I guess it's technically a bug that ThrowIfUncheckedKnownUnchecked fires here. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testThrowIfUnchecked_null() { assertThrows(NullPointerException.class, () -> throwIfUnchecked(null)); } @J2ktIncompatible @GwtIncompatible // propagateIfPossible + // I guess it's technically a bug that ThrowIfUncheckedKnownUnchecked fires here. + @SuppressWarnings("ThrowIfUncheckedKnownUnchecked") public void testPropageIfPossible_null() { propagateIfPossible(null); }