I recently ran into an issue using NioZipEncoding (via
CpioArchiveOutputStream).
The minimal reproducing code snippet looks like this:
```
val encoding = ZipEncodingHelper.getZipEncoding(
StandardCharsets.US_ASCII.name())
encoding.encode("รท")
```
This crashes on Android with "IllegalStateException: Current state =
CODING, new state = CODING" (code
<https://cs.android.com/android/platform/superproject/main/+/main:libcore/ojluni/src/main/java/java/nio/charset/CharsetEncoder.java;l=952;drc=5498505951a9e607d809fc88da616f4249eb414e>
).
My first inclination was to file this bug to Android, but reading the
documentation for CharsetEncoder.canEncode
<https://docs.oracle.com/javase/8/docs/api/java/nio/charset/CharsetEncoder.html>,
it mentions that IllegalStateException is thrown "If an encoding operation
is already in progress". Looks like the code in NioZipEncoding is doing
exactly that.
I believe the reason that it doesn't throw on desktop JVMs is that the Sun
implementation overrides canEncode
<https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/sun/nio/cs/US_ASCII.java#L138>,
whereas on Android they use an alternative implementation that uses the
base implementation in CharsetEncoder.
Maurice