From 41fe5aa1e367926ef6ef2c70d1a2b76b107e7cf3 Mon Sep 17 00:00:00 2001 From: ibaker Date: Tue, 27 Jul 2021 20:27:03 +0100 Subject: [PATCH] Throw IllegalStateException from Util.gzip() instead of AssertionError The documentation on ByteArrayOutputStream and GZIPOutputStream isn't completely clear that an IOException will *never* happen, so AssertionError seems a bit strong - but it seems very unlikely, so we just use IllegalStateException instead. #minor-release PiperOrigin-RevId: 387169297 --- .../main/java/com/google/android/exoplayer2/util/Util.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java index 109768aafc..e222e83ffb 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java @@ -2116,7 +2116,9 @@ public final class Util { try (GZIPOutputStream os = new GZIPOutputStream(output)) { os.write(input); } catch (IOException e) { - throw new AssertionError(e); + // A ByteArrayOutputStream wrapped in a GZipOutputStream should never throw IOException since + // no I/O is happening. + throw new IllegalStateException(e); } return output.toByteArray(); }