summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorgfyoung <gfyoung17@gmail.com>2016-06-11 08:14:51 +0100
committerAli Beyad <ali@elastic.co>2016-07-22 13:48:45 -0400
commitb02a6da8fd69e89ef7d916c239d61aa38f1f9096 (patch)
treefffc1d1ab95882a65c5391e2d2cf20c38f14229e /plugins
parent0620a3d6c26c13c2dfcc49ff2552bdbe608cfd7a (diff)
Properly raise IOException for Azure, Fs, Hdfs, and S3
Diffstat (limited to 'plugins')
-rw-r--r--plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobContainer.java5
-rw-r--r--plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobContainer.java16
-rw-r--r--plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java4
3 files changed, 15 insertions, 10 deletions
diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobContainer.java b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobContainer.java
index e6c3a46907..7489a58f1b 100644
--- a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobContainer.java
+++ b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobContainer.java
@@ -70,6 +70,11 @@ public class AzureBlobContainer extends AbstractBlobContainer {
@Override
public InputStream readBlob(String blobName) throws IOException {
logger.trace("readBlob({})", blobName);
+
+ if (!blobExists(blobName)) {
+ throw new IOException("Blob [" + blobName + "] does not exist");
+ }
+
try {
return blobStore.getInputStream(blobStore.container(), buildKey(blobName));
} catch (StorageException e) {
diff --git a/plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobContainer.java b/plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobContainer.java
index 4af2857876..901c4ef13e 100644
--- a/plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobContainer.java
+++ b/plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobContainer.java
@@ -68,16 +68,12 @@ final class HdfsBlobContainer extends AbstractBlobContainer {
@Override
public void deleteBlob(String blobName) throws IOException {
- try {
- store.execute(new Operation<Boolean>() {
- @Override
- public Boolean run(FileContext fileContext) throws IOException {
- return fileContext.delete(new Path(path, blobName), true);
- }
- });
- } catch (FileNotFoundException e) {
- throw new IOException(e);
- }
+ store.execute(new Operation<Boolean>() {
+ @Override
+ public Boolean run(FileContext fileContext) throws IOException {
+ return fileContext.delete(new Path(path, blobName), true);
+ }
+ });
}
@Override
diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java
index ea71dc152f..41604577ea 100644
--- a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java
+++ b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java
@@ -115,6 +115,10 @@ public class S3BlobContainer extends AbstractBlobContainer {
@Override
public void deleteBlob(String blobName) throws IOException {
+ if (!blobExists(blobName)) {
+ throw new IOException("Blob [" + blobName + "] does not exist");
+ }
+
try {
blobStore.client().deleteObject(blobStore.bucket(), buildKey(blobName));
} catch (AmazonClientException e) {