iamsanjaymalakar opened a new pull request, #8731: URL: https://github.com/apache/hadoop/pull/8731
### Problem `org.apache.hadoop.hdfs.server.datanode.DataNode.requestShortCircuitFdsForRead()` opens the block data stream into `fis[0]` before opening the metadata stream into `fis[1]`. `org.apache.hadoop.hdfs.server.datanode.DatanodeUtil.getMetaDataInputStream()` (and `checkStorageState` / `getBlockInputStream`) can throw `java.io.IOException`. The catch clause handles only `java.lang.ClassCastException`, so the `java.io.IOException` propagates with `fis[0]` already open. The `fis` array is never returned on that path, so `fis[0]` is leaked. ### Change * Add a `java.io.IOException` catch that closes any stream already stored in `fis` via `org.apache.hadoop.io.IOUtils.cleanupWithLogger` before rethrowing the original exception. * The successful path is unchanged. ### Testing * `mvn -pl hadoop-hdfs-project/hadoop-hdfs -am -Dtest=TestDataNodeShortCircuitFds test` * New test `TestDataNodeShortCircuitFds#testClosesBlockStreamWhenMetadataStreamFails` fails against the previous code and passes with the change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
