[
https://issues.apache.org/jira/browse/HDFS-17979?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18114734#comment-18114734
]
ASF GitHub Bot commented on HDFS-17979:
---------------------------------------
ayushtkn commented on code in PR #8732:
URL: https://github.com/apache/hadoop/pull/8732#discussion_r3998867087
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/TeeOutputStream.java:
##########
@@ -53,8 +53,20 @@ public void write(byte[] b, int off, int len) throws
IOException {
@Override
public void close() throws IOException {
+ IOException exception = null;
for (OutputStream o : outs) {
- o.close();
+ try {
+ o.close();
+ } catch (IOException e) {
+ if (exception == null) {
+ exception = e;
+ } else {
+ exception.addSuppressed(e);
+ }
+ }
+ }
+ if (exception != null) {
+ throw exception;
}
}
Review Comment:
This should do IMO
```
IOUtils.closeStreams(outs);
```
> TeeOutputStream.close() should close every wrapped output
> ---------------------------------------------------------
>
> Key: HDFS-17979
> URL: https://issues.apache.org/jira/browse/HDFS-17979
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: tools
> Affects Versions: 3.4.1
> Reporter: Sanjay Malakar
> Priority: Minor
> Labels: pull-request-available
>
> The OfflineEditsViewer
> \{{org.apache.hadoop.hdfs.tools.offlineEditsViewer.TeeOutputStream.close()}}
> closes its wrapped output streams in a for-each loop. If one
> \{{java.io.OutputStream.close()}} call throws \{{java.io.IOException}}, the
> loop exits and every later output is left open.
> {\{close()}} should attempt every output, keep the first
> \{{java.io.IOException}}, attach later failures as suppressed exceptions, and
> throw the first one after every output has been attempted. This mirrors the
> fix in ZOOKEEPER-5055 for \{{FileTxnLog.close()}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]