Skip to content

Commit 6cbcd97

Browse files
author
Likitha Shetty
committed
CLOUDSTACK-3139 - If management server doesn't have internet connection RegisterTemplate and UploadVolume will fail when CS tries to verify if the account has exceeded its secondary storage limit.
No change in behavior if management server has internet connection. Now if management server doesn't have internet connection download process will not fail. But CS will noly check if the account has already reached or maxed its limits instead of checking if the limit will be breached with the addition of the new storage
1 parent 3364e29 commit 6cbcd97

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎utils/src/com/cloud/utils/UriUtils.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,22 @@ public static Long getRemoteSize(String url) {
110110
URI uri = new URI(url);
111111
if(uri.getScheme().equalsIgnoreCase("http")) {
112112
httpConn = (HttpURLConnection) uri.toURL().openConnection();
113-
remoteSize = Long.parseLong(httpConn.getHeaderField("content-length"));
113+
if (httpConn != null) {
114+
remoteSize = Long.parseLong(httpConn.getHeaderField("content-length"));
115+
httpConn.disconnect();
116+
}
114117
}
115118
else if(uri.getScheme().equalsIgnoreCase("https")) {
116119
httpsConn = (HttpsURLConnection) uri.toURL().openConnection();
117-
remoteSize = Long.parseLong(httpsConn.getHeaderField("content-length"));
120+
if (httpsConn != null) {
121+
remoteSize = Long.parseLong(httpsConn.getHeaderField("content-length"));
122+
httpsConn.disconnect();
123+
}
118124
}
119125
} catch (URISyntaxException e) {
120126
throw new IllegalArgumentException("Invalid URL " + url);
121127
} catch (IOException e) {
122128
throw new IllegalArgumentException("Unable to establish connection with URL " + url);
123-
} finally {
124-
if (httpConn != null) {
125-
httpConn.disconnect();
126-
} else if (httpsConn != null) {
127-
httpsConn.disconnect();
128-
}
129129
}
130130
return remoteSize;
131131
}

0 commit comments

Comments
 (0)