mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8313739: ZipOutputStream.close() should always close the wrapped stream
Reviewed-by: jpai, lancea
This commit is contained in:
parent
adc3604027
commit
f613e13397
2 changed files with 281 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -240,14 +240,30 @@ public class DeflaterOutputStream extends FilterOutputStream {
|
|||
*/
|
||||
public void close() throws IOException {
|
||||
if (!closed) {
|
||||
closed = true;
|
||||
IOException finishException = null;
|
||||
try {
|
||||
finish();
|
||||
} catch (IOException ioe){
|
||||
finishException = ioe;
|
||||
throw ioe;
|
||||
} finally {
|
||||
if (usesDefaultDeflater)
|
||||
if (usesDefaultDeflater) {
|
||||
def.end();
|
||||
}
|
||||
if (finishException == null) {
|
||||
out.close();
|
||||
} else {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ioe) {
|
||||
if (finishException != ioe) {
|
||||
ioe.addSuppressed(finishException);
|
||||
}
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
}
|
||||
out.close();
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue