Catch, log, and retry on IOException for HTTP cluster metadata URLs
Change-Id: Id43c41c4d2f6f9b29012db308db301bca0b99668
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java b/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
index b097e2a..6d5abf1 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
@@ -204,16 +204,21 @@
version = file.lastModified();
metadata = mapper.readValue(new FileInputStream(file), ClusterMetadata.class);
} else if ("http".equals(url.getProtocol())) {
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- if (conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
+ try {
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ if (conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
+ log.warn("Could not reach metadata URL {}. Retrying...", url);
+ return null;
+ }
+ if (conn.getResponseCode() == HttpURLConnection.HTTP_NO_CONTENT) {
+ return null;
+ }
+ version = conn.getLastModified();
+ metadata = mapper.readValue(conn.getInputStream(), ClusterMetadata.class);
+ } catch (IOException e) {
log.warn("Could not reach metadata URL {}. Retrying...", url);
return null;
}
- if (conn.getResponseCode() == HttpURLConnection.HTTP_NO_CONTENT) {
- return null;
- }
- version = conn.getLastModified();
- metadata = mapper.readValue(conn.getInputStream(), ClusterMetadata.class);
}
if (null == metadata) {