Fix ConcatReader.close() to close all readers on failure

This commit is contained in:
Sanjay Malakar
2026-03-09 07:59:33 +00:00
parent 1ccdca549c
commit 6474f912a4
2 changed files with 16 additions and 2 deletions

View File

@@ -383,10 +383,17 @@ public class ConcatReader extends Reader {
@Override
public void close() throws IOException {
if (closed) return;
IOException first = null;
for (Reader reader : readerQueue) {
reader.close();
try {
reader.close();
} catch (IOException e) {
if (first == null) first = e;
else first.addSuppressed(e);
}
}
closed = true;
if (first != null) throw first;
}
/**

View File

@@ -381,10 +381,17 @@ public class ConcatReader extends Reader {
@Override
public void close() throws IOException {
if (closed) return;
IOException first = null;
for (Reader reader : readerQueue) {
reader.close();
try {
reader.close();
} catch (IOException e) {
if (first == null) first = e;
else first.addSuppressed(e);
}
}
closed = true;
if (first != null) throw first;
}
/**