From 6cbcd9777deabd75dbe4694cc492276d2d8ad01b Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Tue, 30 Jul 2013 16:54:09 +0530 Subject: [PATCH] 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 --- utils/src/com/cloud/utils/UriUtils.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/utils/src/com/cloud/utils/UriUtils.java b/utils/src/com/cloud/utils/UriUtils.java index b9d54d5cbc4..6618e441afd 100644 --- a/utils/src/com/cloud/utils/UriUtils.java +++ b/utils/src/com/cloud/utils/UriUtils.java @@ -110,22 +110,22 @@ public class UriUtils { URI uri = new URI(url); if(uri.getScheme().equalsIgnoreCase("http")) { httpConn = (HttpURLConnection) uri.toURL().openConnection(); - remoteSize = Long.parseLong(httpConn.getHeaderField("content-length")); + if (httpConn != null) { + remoteSize = Long.parseLong(httpConn.getHeaderField("content-length")); + httpConn.disconnect(); + } } else if(uri.getScheme().equalsIgnoreCase("https")) { httpsConn = (HttpsURLConnection) uri.toURL().openConnection(); - remoteSize = Long.parseLong(httpsConn.getHeaderField("content-length")); + if (httpsConn != null) { + remoteSize = Long.parseLong(httpsConn.getHeaderField("content-length")); + httpsConn.disconnect(); + } } } catch (URISyntaxException e) { throw new IllegalArgumentException("Invalid URL " + url); } catch (IOException e) { throw new IllegalArgumentException("Unable to establish connection with URL " + url); - } finally { - if (httpConn != null) { - httpConn.disconnect(); - } else if (httpsConn != null) { - httpsConn.disconnect(); - } } return remoteSize; }