From 9911c8347f59462da22a06ebc464f3c6a7fec76c Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 21 Oct 2024 09:25:13 -0700 Subject: [PATCH] Internal change. RELNOTES=n/a PiperOrigin-RevId: 688163700 --- .../google/common/io/BaseEncodingTest.java | 49 ++++++++++--------- .../common/io/ReflectionFreeAssertThrows.java | 4 -- .../google/common/io/BaseEncodingTest.java | 49 ++++++++++--------- .../common/io/ReflectionFreeAssertThrows.java | 4 -- 4 files changed, 54 insertions(+), 52 deletions(-) diff --git a/android/guava-tests/test/com/google/common/io/BaseEncodingTest.java b/android/guava-tests/test/com/google/common/io/BaseEncodingTest.java index 5abce94e6ad8..25b9787235cd 100644 --- a/android/guava-tests/test/com/google/common/io/BaseEncodingTest.java +++ b/android/guava-tests/test/com/google/common/io/BaseEncodingTest.java @@ -450,28 +450,6 @@ private static void assertFailsToDecode( } enum AssertFailsToDecodeStrategy { - @GwtIncompatible // decodingStream(Reader) - DECODING_STREAM { - @Override - void assertFailsToDecode( - BaseEncoding encoding, String cannotDecode, @Nullable String expectedMessage) { - // Regression test for case where DecodingException was swallowed by default implementation - // of - // InputStream.read(byte[], int, int) - // See https://github.com/google/guava/issues/3542 - Reader reader = new StringReader(cannotDecode); - InputStream decodingStream = encoding.decodingStream(reader); - try { - ByteStreams.exhaust(decodingStream); - fail("Expected DecodingException"); - } catch (DecodingException expected) { - // Don't assert on the expectedMessage; the messages for exceptions thrown from the - // decoding stream may differ from the messages for the decode methods. - } catch (IOException e) { - fail("Expected DecodingException but got: " + e); - } - } - }, CAN_DECODE { @Override void assertFailsToDecode( @@ -506,6 +484,33 @@ void assertFailsToDecode( } } } + }, + /* + * This one comes last to work around b/367716565. (One *possible* alternative would be to not + * declare any methods in this enum, converting assertFailsToDecode into a static method that is + * implemented with a `switch`. I haven't tested that.) + */ + @GwtIncompatible // decodingStream(Reader) + DECODING_STREAM { + @Override + void assertFailsToDecode( + BaseEncoding encoding, String cannotDecode, @Nullable String expectedMessage) { + // Regression test for case where DecodingException was swallowed by default implementation + // of + // InputStream.read(byte[], int, int) + // See https://github.com/google/guava/issues/3542 + Reader reader = new StringReader(cannotDecode); + InputStream decodingStream = encoding.decodingStream(reader); + try { + ByteStreams.exhaust(decodingStream); + fail("Expected DecodingException"); + } catch (DecodingException expected) { + // Don't assert on the expectedMessage; the messages for exceptions thrown from the + // decoding stream may differ from the messages for the decode methods. + } catch (IOException e) { + fail("Expected DecodingException but got: " + e); + } + } }; abstract void assertFailsToDecode( diff --git a/android/guava-tests/test/com/google/common/io/ReflectionFreeAssertThrows.java b/android/guava-tests/test/com/google/common/io/ReflectionFreeAssertThrows.java index a37d10d5b955..444185d69ff0 100644 --- a/android/guava-tests/test/com/google/common/io/ReflectionFreeAssertThrows.java +++ b/android/guava-tests/test/com/google/common/io/ReflectionFreeAssertThrows.java @@ -22,8 +22,6 @@ import com.google.common.base.Predicate; import com.google.common.base.VerifyException; import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ExecutionError; -import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.reflect.InvocationTargetException; import java.nio.charset.UnsupportedCharsetException; @@ -134,7 +132,6 @@ ImmutableMap, Predicate> exceptions() { .put( ConcurrentModificationException.class, e -> e instanceof ConcurrentModificationException) - .put(ExecutionError.class, e -> e instanceof ExecutionError) .put(ExecutionException.class, e -> e instanceof ExecutionException) .put(IllegalArgumentException.class, e -> e instanceof IllegalArgumentException) .put(IllegalStateException.class, e -> e instanceof IllegalStateException) @@ -144,7 +141,6 @@ ImmutableMap, Predicate> exceptions() { .put(NumberFormatException.class, e -> e instanceof NumberFormatException) .put(RuntimeException.class, e -> e instanceof RuntimeException) .put(TimeoutException.class, e -> e instanceof TimeoutException) - .put(UncheckedExecutionException.class, e -> e instanceof UncheckedExecutionException) .put(UnsupportedCharsetException.class, e -> e instanceof UnsupportedCharsetException) .put(UnsupportedOperationException.class, e -> e instanceof UnsupportedOperationException) .put(VerifyException.class, e -> e instanceof VerifyException) diff --git a/guava-tests/test/com/google/common/io/BaseEncodingTest.java b/guava-tests/test/com/google/common/io/BaseEncodingTest.java index 5abce94e6ad8..25b9787235cd 100644 --- a/guava-tests/test/com/google/common/io/BaseEncodingTest.java +++ b/guava-tests/test/com/google/common/io/BaseEncodingTest.java @@ -450,28 +450,6 @@ private static void assertFailsToDecode( } enum AssertFailsToDecodeStrategy { - @GwtIncompatible // decodingStream(Reader) - DECODING_STREAM { - @Override - void assertFailsToDecode( - BaseEncoding encoding, String cannotDecode, @Nullable String expectedMessage) { - // Regression test for case where DecodingException was swallowed by default implementation - // of - // InputStream.read(byte[], int, int) - // See https://github.com/google/guava/issues/3542 - Reader reader = new StringReader(cannotDecode); - InputStream decodingStream = encoding.decodingStream(reader); - try { - ByteStreams.exhaust(decodingStream); - fail("Expected DecodingException"); - } catch (DecodingException expected) { - // Don't assert on the expectedMessage; the messages for exceptions thrown from the - // decoding stream may differ from the messages for the decode methods. - } catch (IOException e) { - fail("Expected DecodingException but got: " + e); - } - } - }, CAN_DECODE { @Override void assertFailsToDecode( @@ -506,6 +484,33 @@ void assertFailsToDecode( } } } + }, + /* + * This one comes last to work around b/367716565. (One *possible* alternative would be to not + * declare any methods in this enum, converting assertFailsToDecode into a static method that is + * implemented with a `switch`. I haven't tested that.) + */ + @GwtIncompatible // decodingStream(Reader) + DECODING_STREAM { + @Override + void assertFailsToDecode( + BaseEncoding encoding, String cannotDecode, @Nullable String expectedMessage) { + // Regression test for case where DecodingException was swallowed by default implementation + // of + // InputStream.read(byte[], int, int) + // See https://github.com/google/guava/issues/3542 + Reader reader = new StringReader(cannotDecode); + InputStream decodingStream = encoding.decodingStream(reader); + try { + ByteStreams.exhaust(decodingStream); + fail("Expected DecodingException"); + } catch (DecodingException expected) { + // Don't assert on the expectedMessage; the messages for exceptions thrown from the + // decoding stream may differ from the messages for the decode methods. + } catch (IOException e) { + fail("Expected DecodingException but got: " + e); + } + } }; abstract void assertFailsToDecode( diff --git a/guava-tests/test/com/google/common/io/ReflectionFreeAssertThrows.java b/guava-tests/test/com/google/common/io/ReflectionFreeAssertThrows.java index a37d10d5b955..444185d69ff0 100644 --- a/guava-tests/test/com/google/common/io/ReflectionFreeAssertThrows.java +++ b/guava-tests/test/com/google/common/io/ReflectionFreeAssertThrows.java @@ -22,8 +22,6 @@ import com.google.common.base.Predicate; import com.google.common.base.VerifyException; import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ExecutionError; -import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.reflect.InvocationTargetException; import java.nio.charset.UnsupportedCharsetException; @@ -134,7 +132,6 @@ ImmutableMap, Predicate> exceptions() { .put( ConcurrentModificationException.class, e -> e instanceof ConcurrentModificationException) - .put(ExecutionError.class, e -> e instanceof ExecutionError) .put(ExecutionException.class, e -> e instanceof ExecutionException) .put(IllegalArgumentException.class, e -> e instanceof IllegalArgumentException) .put(IllegalStateException.class, e -> e instanceof IllegalStateException) @@ -144,7 +141,6 @@ ImmutableMap, Predicate> exceptions() { .put(NumberFormatException.class, e -> e instanceof NumberFormatException) .put(RuntimeException.class, e -> e instanceof RuntimeException) .put(TimeoutException.class, e -> e instanceof TimeoutException) - .put(UncheckedExecutionException.class, e -> e instanceof UncheckedExecutionException) .put(UnsupportedCharsetException.class, e -> e instanceof UnsupportedCharsetException) .put(UnsupportedOperationException.class, e -> e instanceof UnsupportedOperationException) .put(VerifyException.class, e -> e instanceof VerifyException)