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
This commit is contained in:
parent
1aa76b5fdc
commit
41fe5aa1e3
@ -2116,7 +2116,9 @@ public final class Util {
|
|||||||
try (GZIPOutputStream os = new GZIPOutputStream(output)) {
|
try (GZIPOutputStream os = new GZIPOutputStream(output)) {
|
||||||
os.write(input);
|
os.write(input);
|
||||||
} catch (IOException e) {
|
} 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();
|
return output.toByteArray();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user