Skip to content

Commit 7c27d53

Browse files
committed
[cleanup] collapse identical catch blocks
With Java7, you don't need multiple identical catch blocks anymore Related to #52. (cherry picked from commit 322e1e5) (cherry picked from commit 9d3b0ad)
1 parent 0e81e35 commit 7c27d53

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

src/main/java/org/elasticsearch/cloud/azure/AzureComputeServiceImpl.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ public Set<Instance> instances() {
117117
Set<Instance> instances = buildInstancesFromXml(stream, port_name);
118118
logger.trace("get instances from azure: {}", instances);
119119
return instances;
120-
} catch (ParserConfigurationException e) {
121-
logger.warn("can not parse XML response: {}", e.getMessage());
122-
} catch (XPathExpressionException e) {
123-
logger.warn("can not parse XML response: {}", e.getMessage());
124-
} catch (SAXException e) {
120+
} catch (ParserConfigurationException | XPathExpressionException | SAXException e) {
125121
logger.warn("can not parse XML response: {}", e.getMessage());
126122
} catch (Exception e) {
127123
logger.warn("can not get list of azure nodes: {}", e.getMessage());

src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobContainer.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ public AzureBlobContainer(BlobPath path, AzureBlobStore blobStore) {
6060
public boolean blobExists(String blobName) {
6161
try {
6262
return blobStore.client().blobExists(blobStore.container(), buildKey(blobName));
63-
} catch (URISyntaxException e) {
64-
logger.warn("can not access [{}] in container {{}}: {}", blobName, blobStore.container(), e.getMessage());
65-
} catch (StorageException e) {
63+
} catch (URISyntaxException | StorageException e) {
6664
logger.warn("can not access [{}] in container {{}}: {}", blobName, blobStore.container(), e.getMessage());
6765
}
6866
return false;
@@ -98,10 +96,7 @@ public OutputStream createOutput(String blobName) throws IOException {
9896
public void deleteBlob(String blobName) throws IOException {
9997
try {
10098
blobStore.client().deleteBlob(blobStore.container(), buildKey(blobName));
101-
} catch (URISyntaxException e) {
102-
logger.warn("can not access [{}] in container {{}}: {}", blobName, blobStore.container(), e.getMessage());
103-
throw new IOException(e);
104-
} catch (StorageException e) {
99+
} catch (URISyntaxException | StorageException e) {
105100
logger.warn("can not access [{}] in container {{}}: {}", blobName, blobStore.container(), e.getMessage());
106101
throw new IOException(e);
107102
}
@@ -112,13 +107,7 @@ public ImmutableMap<String, BlobMetaData> listBlobsByPrefix(@Nullable String pre
112107

113108
try {
114109
return blobStore.client().listBlobsByPrefix(blobStore.container(), keyPath, prefix);
115-
} catch (URISyntaxException e) {
116-
logger.warn("can not access [{}] in container {{}}: {}", prefix, blobStore.container(), e.getMessage());
117-
throw new IOException(e);
118-
} catch (StorageException e) {
119-
logger.warn("can not access [{}] in container {{}}: {}", prefix, blobStore.container(), e.getMessage());
120-
throw new IOException(e);
121-
} catch (ServiceException e) {
110+
} catch (URISyntaxException | StorageException | ServiceException e) {
122111
logger.warn("can not access [{}] in container {{}}: {}", prefix, blobStore.container(), e.getMessage());
123112
throw new IOException(e);
124113
}

src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ public void delete(BlobPath path) {
7676

7777
try {
7878
client.deleteFiles(container, keyPath);
79-
} catch (URISyntaxException e) {
80-
logger.warn("can not remove [{}] in container {{}}: {}", keyPath, container, e.getMessage());
81-
} catch (StorageException e) {
82-
logger.warn("can not remove [{}] in container {{}}: {}", keyPath, container, e.getMessage());
83-
} catch (ServiceException e) {
79+
} catch (URISyntaxException | StorageException | ServiceException e) {
8480
logger.warn("can not remove [{}] in container {{}}: {}", keyPath, container, e.getMessage());
8581
}
8682
}

0 commit comments

Comments
 (0)