mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Fix file handle leak in URLBlobContainer
This commit is contained in:
parent
c324251fc2
commit
0a7c6c9288
@ -96,20 +96,20 @@ public abstract class AbstractURLBlobContainer extends AbstractBlobContainer {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new URL(path, blobName).openStream();
|
||||
} catch (IOException e) {
|
||||
IOUtils.closeWhileHandlingException(is);
|
||||
listener.onFailure(e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int bytesRead;
|
||||
while ((bytesRead = is.read(buffer)) != -1) {
|
||||
listener.onPartial(buffer, 0, bytesRead);
|
||||
}
|
||||
listener.onCompleted();
|
||||
} catch (IOException e) {
|
||||
} catch (Throwable t) {
|
||||
IOUtils.closeWhileHandlingException(is);
|
||||
listener.onFailure(e);
|
||||
listener.onFailure(t);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
IOUtils.closeWhileHandlingException(is);
|
||||
listener.onCompleted();
|
||||
} catch (Throwable t) {
|
||||
listener.onFailure(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user