Skip to content

Commit 929f88a

Browse files
committed
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 92a10fc commit 929f88a

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
@@ -594,10 +594,10 @@ private void login() {
594594

595595
apiVersion = connectionDetails.get(FlashArrayAdapter.API_VERSION);
596596
boolean apiVersionExplicit = apiVersion != null;
597-
if (apiVersion == null) {
597+
if (!apiVersionExplicit) {
598598
apiVersion = queryParms.get(FlashArrayAdapter.API_VERSION);
599599
apiVersionExplicit = apiVersion != null;
600-
if (apiVersion == null) {
600+
if (!apiVersionExplicit) {
601601
apiVersion = API_VERSION_DEFAULT;
602602
}
603603
}
@@ -703,7 +703,11 @@ private void login() {
703703
+ "/api_version, falling back to default " + API_VERSION_DEFAULT, e);
704704
} finally {
705705
if (vResp != null) {
706-
vResp.close();
706+
try {
707+
vResp.close();
708+
} catch (IOException e) {
709+
logger.debug("Error closing /api/api_version response from FlashArray [" + url + "]", e);
710+
}
707711
}
708712
}
709713
}
@@ -737,7 +741,11 @@ private void login() {
737741
"Unexpected HTTP response code from FlashArray [" + url + "] - [" + statusCode
738742
+ "] - " + response.getStatusLine().getReasonPhrase());
739743
}
740-
response.close();
744+
try {
745+
response.close();
746+
} catch (IOException e) {
747+
logger.debug("Error closing legacy auth/apitoken response from FlashArray [" + url + "]", e);
748+
}
741749
response = null;
742750
}
743751

0 commit comments

Comments
 (0)