On Fri, 20 Mar 2026 17:07:18 GMT, Eirik Bjørsnøs <[email protected]> wrote:

>>> > ZipOutputStream::setComment and other setXXf methods throw 
>>> > IllegalArgumentException vs ZipException per the javadocs so we have a 
>>> > difference to deal as part of how we address the issue
>> 
>>> I don't think I understand what you suggest here. You mean methods in 
>>> ZipCoder as Alan suggested? What do you think about my idea to consolidate 
>>> ZipCoder methods to throw mostly CharacterCodingException, as suggested in 
>>> a reply to Alan above?
>> 
>> Apologies for not b being clearer.  I would like to avoid the extra 
>> try-with-resources in putNextEntry() if we can
>> 
>> I see writeLOC does
>> 
>> `byte[] nameBytes = zc.getBytes(e.name);`
>> 
>> We will probably want to throw ZipException here
>
>> Apologies for not b being clearer. I would like to avoid the extra 
>> try-with-resources in putNextEntry() if we can
> 
> I think this validation needs to happen early, in `putNextEntry`, before 
> adding the entry  to `xentries`. 
> 
> Once the entry get added, it sets it up for processing during 
> `ZipOutputStream::close` where `writeCEN` called.
> 
> If we want to avoid calling zc.getBytes(e.name) twice, we could capture the 
> byte array in putNextEntry, then pass it as a parameter to `writeLOC`. We 
> could potentially also capture in the the `XEntry`, but that would add to 
> retained heap memory, so I'm slightly reluctant to that.

Yes I see what you are saying and I agree with the validation happening 
earlier.  I just want to avoid multiple try blocks for this.  Could do 
something similar to  ZipFile::initCen which keeps it tidier

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30319#discussion_r2967598661

Reply via email to