Github user revans2 commented on a diff in the pull request:
https://github.com/apache/storm/pull/1787#discussion_r88930878
--- Diff:
external/storm-hdfs/src/main/java/org/apache/storm/hdfs/trident/HdfsState.java
---
@@ -500,6 +500,7 @@ private void updateIndex(long txId) {
bw.write(txnRecord.toString());
bw.newLine();
bw.flush();
+ out.close(); // Closing the output stream in finally
block causes FileNotFoundException in Azure Data Lake Store file system (adl://)
--- End diff --
Why not just wrap the output stream in a try block instead?
```
Path tmpPath = tmpFilePath(indexFilePath.toString());
TxnRecord txnRecord = new TxnRecord(txId, options.currentFile.toString(),
this.options.getCurrentOffset());
try (FSDataOutputStream out = this.options.fs.create(tmpPath, true);
BufferedWriter bw = new BufferedWriter(new
OutputStreamWriter(out));) {
bw.write(txnRecord.toString());
bw.newLine();
bw.flush();
}
```
Then you don't need to worry about the close happening before the delete,
even in error cases.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---