RFR: 8303972: Make test/jdk/jdk/nio/zipfs/TestLocOffsetFromZip64EF.java independent of the zip command line [v3]

Eirik Bjorsnos duke at openjdk.org
Fri Mar 10 21:18:14 UTC 2023


On Fri, 10 Mar 2023 15:48:40 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Eirik Bjorsnos has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   The Zip64 fields are all zero, we don't need to update them
>
> test/jdk/jdk/nio/zipfs/TestLocOffsetFromZip64EF.java line 136:
> 
>> 134:         // Make a ZIP with two entries
>> 135:         try (FileOutputStream fileOutputStream = new FileOutputStream(new File(ZIP_FILE_NAME));
>> 136:              ZipOutputStream zo = new ZipOutputStream(new SparseOutputStream(fileOutputStream))) {
> 
> Can you use FileChannel.open and specify SPARSE in the set of open options, I think that would make it clearer that the file is sparse and remove the need for SparseOutputStream.

Not sure I understand. I could use FileChannel.open with SPARSE (which btw is ignored by the implementation:), but that doesn't give me an OutputStream I can pass to ZipOutputStream?

I could use Channels.newOutputStream, but that would not create holes in the sparse files?

My current thinking is that we need the SparseOutputStream to detect that ZIpOutputStream is writing empty bytes and replace that with `channel.position(channel.position() + len)`

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

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


More information about the nio-dev mailing list