Request for Review: 7094995: test/java/util/zip/ZipFile/ causes continuous GC in agentvm mode

David Holmes david.holmes at
Thu Nov 24 01:22:00 UTC 2011

Hi Joe,

On 24/11/2011 2:33 AM, Joe Darcy wrote:
> On 11/22/2011 9:57 PM, David Holmes wrote:
>> On 22/11/2011 9:51 PM, Neil Richards wrote:
>>> I've also converted the testcase's use of ZipFile, ZipOutputStream&
>>> FileOutputStream to use ARM (for greater clarity).
>> I think proper use of ARM requires that this:
>> 66 try (ZipOutputStream zos =
>> 67 new ZipOutputStream(new FileOutputStream(tempZipFile))) {
>> be written as:
>> try (FileOutputStream fos = new FileOutputStream(tempZipFile);
>> ZipOutputStream zos = new ZipOutputStream(fos)) {
> The more conservative approach is to define one resource variable per
> logical resource even if the one resource is "wrapped" by the second
> one, as in the second example. This does close the small window of
> vulnerability between when the first constructor call ends and the
> second one completes. However, if that pattern is used, it is important
> for the close method of the inner resource to be idempotent, as required
> by the type but *not* required by
> java.lang.AutoCloseable.

Sorry but I couldn't quite tell what you were recommending there. Is the 
original code or my change the preferred approach? As I understood it 
the original code would not close the FileOutputStream if the 
ZipOutputStream constructor threw an exception.


More information about the core-libs-dev mailing list