Skip to content

Commit

Permalink
prevent fd leakage when WorkerUtils.downloadFromBookkeeper (apache#4970)
Browse files Browse the repository at this point in the history
Fixes apache#4969

### Motivation

close `FileOutputStream` after `WorkerUtils.downloadFromBookkeeper`
  • Loading branch information
freeznet authored and sijie committed Aug 18, 2019
1 parent 93d95c7 commit 2c21500
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,14 @@ private void downloadFile(File pkgFile, boolean isPkgUrlProvided, FunctionMetaDa
if(downloadFromHttp) {
FunctionCommon.downloadFromHttpUrl(pkgLocationPath, tempPkgFile);
} else {
FileOutputStream tempPkgFos = new FileOutputStream(tempPkgFile);
WorkerUtils.downloadFromBookkeeper(
dlogNamespace,
new FileOutputStream(tempPkgFile),
tempPkgFos,
pkgLocationPath);
if (tempPkgFos != null) {
tempPkgFos.close();
}
}

try {
Expand Down

0 comments on commit 2c21500

Please sign in to comment.