> Please review this PR which improves validation of unmappable characters in 
> names in the `ZipFileSystem` and `ZipFileOutputStream` APIs.
> 
> Currently, `ZipFileSystem::getPath` and `ZipFileOutputStream:putNextEntry` 
> both throw `IllegalArgumentException` when rejecting a path or entry name 
> which cannot be encoded with the given charset. 
> 
> This PR fixes `ZipFileSystem::getPath` to instead throw 
> `InvalidPathException` as specified. Similarly, 
> `ZipOutputStream::putNextEntry` is updated to throw `ZipException` a 
> specified.
> 
> Related, `ZipOutputStream::putNextEntry` is updated to reject unmappable 
> ZipEntry comments in a similar fashion.
> 
> This change effectively means that `ZipOutputStream` now encodes names and 
> comments twice, once in `putNextEntry` and second time in `writeCEN` when the 
> stream is closed. An alternative would be to capture the encoded byte arrays 
> in the `XEntry`, however this would increase retained heap memory for large 
> number of entries.
> 
> New tests are added in the ZipFS and ZipFileOutputStream area to verify that 
> these APIs throw exceptions according to their specifications when faced with 
> unmappable characters.

Eirik Bjørsnøs has updated the pull request incrementally with two additional 
commits since the last revision:

 - Extract checkEncodable method to reduce boilerplate
 - The initCause with IllegalArgumentException is not very useful

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/30319/files
  - new: https://git.openjdk.org/jdk/pull/30319/files/8b2ccc05..75ed542b

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=30319&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=30319&range=03-04

  Stats: 23 lines in 2 files changed: 9 ins; 11 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/30319.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/30319/head:pull/30319

PR: https://git.openjdk.org/jdk/pull/30319

Reply via email to