Skip to content

Commit 50b560a

Browse files
genegrEugenio Grosso
authored andcommitted
flasharray: address review on login()
- Replace nested null-check of apiVersion with !apiVersionExplicit for clarity (sureshanaparti). - Wrap vResp.close() in the api_version-discovery finally with its own try/catch; log any IOException at debug so a failed close does not mask a successful discovery. - Wrap the explicit response.close() after the legacy username/password auth with try/catch for the same reason. Signed-off-by: Eugenio Grosso <eugenio.grosso@gmail.com>
1 parent 36a732b commit 50b560a

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • plugins/storage/volume/flasharray/src/main/java/org/apache/cloudstack/storage/datastore/adapter/flasharray

plugins/storage/volume/flasharray/src/main/java/org/apache/cloudstack/storage/datastore/adapter/flasharray/FlashArrayAdapter.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,10 @@ private void login() {
593593

594594
apiVersion = connectionDetails.get(FlashArrayAdapter.API_VERSION);
595595
boolean apiVersionExplicit = apiVersion != null;
596-
if (apiVersion == null) {
596+
if (!apiVersionExplicit) {
597597
apiVersion = queryParms.get(FlashArrayAdapter.API_VERSION);
598598
apiVersionExplicit = apiVersion != null;
599-
if (apiVersion == null) {
599+
if (!apiVersionExplicit) {
600600
apiVersion = API_VERSION_DEFAULT;
601601
}
602602
}
@@ -702,7 +702,11 @@ private void login() {
702702
+ "/api_version, falling back to default " + API_VERSION_DEFAULT, e);
703703
} finally {
704704
if (vResp != null) {
705-
vResp.close();
705+
try {
706+
vResp.close();
707+
} catch (IOException e) {
708+
logger.debug("Error closing /api/api_version response from FlashArray [" + url + "]", e);
709+
}
706710
}
707711
}
708712
}
@@ -736,7 +740,11 @@ private void login() {
736740
"Unexpected HTTP response code from FlashArray [" + url + "] - [" + statusCode
737741
+ "] - " + response.getStatusLine().getReasonPhrase());
738742
}
739-
response.close();
743+
try {
744+
response.close();
745+
} catch (IOException e) {
746+
logger.debug("Error closing legacy auth/apitoken response from FlashArray [" + url + "]", e);
747+
}
740748
response = null;
741749
}
742750

0 commit comments

Comments
 (0)