mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8136895: Writer not closed with disk full error, file resource leaked
Reviewed-by: djelinski, vtewari
This commit is contained in:
parent
8042a50b99
commit
d55d7e8d87
4 changed files with 190 additions and 17 deletions
|
@ -414,8 +414,8 @@ public final class StreamEncoder extends Writer {
|
|||
}
|
||||
|
||||
void implClose() throws IOException {
|
||||
flushLeftoverChar(null, true);
|
||||
try {
|
||||
try (ch; out) {
|
||||
flushLeftoverChar(null, true);
|
||||
for (;;) {
|
||||
CoderResult cr = encoder.flush(bb);
|
||||
if (cr.isUnderflow())
|
||||
|
@ -430,15 +430,8 @@ public final class StreamEncoder extends Writer {
|
|||
|
||||
if (bb.position() > 0)
|
||||
writeBytes();
|
||||
if (ch != null)
|
||||
ch.close();
|
||||
else {
|
||||
try {
|
||||
out.flush();
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
if (out != null)
|
||||
out.flush();
|
||||
} catch (IOException x) {
|
||||
encoder.reset();
|
||||
throw x;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue