Request for Discussion: 8253952: Work around wrong usage of ZipOutputStream.putNextEntry() in user code

Alan Bateman Alan.Bateman at oracle.com
Sat Oct 3 19:11:10 UTC 2020


On 02/10/2020 20:44, Volker Simonis wrote:
> Hi,
>
> I'd like to get your opinion on a workaround for a common but wrong
> usage pattern of ZipOutputStream.putNextEntry() in user code. I've
> created a Draft PR with all the gory details (which I'll include here
> for your convenience). Please let me know what you think?
>
java.util.zip is JDK 1.1 era API and has several usability issues.Yes, 
ZOS.putNextEntry method can be a hazard. Adding an @apiNote with an 
example showing how to use API correctly shouldn't be an issue. I don't 
think the proposal to add a system property to change the behavior is 
feasible, at least not without changing the spec but even then it would 
be very icky. Have you explored adding a better API instead of a 
workaround? It wouldn't be hard to have ZipEntry define a writeTo or 
transferTo method for example.

-Alan.


More information about the core-libs-dev mailing list