Skip to content

Commit

Permalink
better handling of exceptions
Browse files Browse the repository at this point in the history
relates to elastic#161
  • Loading branch information
costin committed Mar 5, 2014
1 parent 8289497 commit 60ce997
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ public void writeBlob(final String blobName, final InputStream is, final long si
blobStore.executor().execute(new Runnable() {
@Override
public void run() {
Path file = new Path(path, blobName);

Path file;
FSDataOutputStream fileStream;

try {
file = new Path(path, blobName);
fileStream = blobStore.fileSystem().create(file, true);
} catch (IOException e) {
listener.onFailure(e);
} catch (Throwable th) {
listener.onFailure(th);
return;
}
try {
Expand All @@ -60,16 +61,16 @@ public void run() {
IOUtils.closeStream(fileStream);
}
listener.onCompleted();
} catch (Exception e) {
} catch (Throwable th) {
// just on the safe size, try and delete it on failure
try {
if (blobStore.fileSystem().exists(file)) {
blobStore.fileSystem().delete(file, true);
}
} catch (Exception e1) {
} catch (Throwable t) {
// ignore
}
listener.onFailure(e);
listener.onFailure(th);
}
}
});
Expand Down

0 comments on commit 60ce997

Please sign in to comment.