Skip to content

Commit e32f16b

Browse files
committed
Fix file handle leak in readBlob method of AbstractFsBlobContainer
1 parent 2b57770 commit e32f16b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,17 @@ public void run() {
8484
FileInputStream is = null;
8585
try {
8686
is = new FileInputStream(new File(path, blobName));
87-
} catch (FileNotFoundException e) {
88-
IOUtils.closeWhileHandlingException(is);
89-
listener.onFailure(e);
90-
return;
91-
}
92-
try {
9387
int bytesRead;
9488
while ((bytesRead = is.read(buffer)) != -1) {
9589
listener.onPartial(buffer, 0, bytesRead);
9690
}
97-
listener.onCompleted();
98-
} catch (Exception e) {
91+
} catch (Throwable e) {
9992
IOUtils.closeWhileHandlingException(is);
10093
listener.onFailure(e);
94+
return;
10195
}
96+
IOUtils.closeWhileHandlingException(is);
97+
listener.onCompleted();
10298
}
10399
});
104100
}

0 commit comments

Comments
 (0)