aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorshashikanth <shashikanth.vh@huawei.com>2017-09-27 17:58:34 +0530
committerShashikanth VH <shashikanth.vh@huawei.com>2017-09-28 05:19:54 +0000
commitc484e22cd6c0b379abb919ce5c81905331a390ab (patch)
treed6793ce2cf21cda2946d607c8887e2fbdccbc74d /src/main/java/org
parent6beac67840ae725879adb59d5bea1aa8cd8f3789 (diff)
Fixed null pointer Blocker/Critical sonar issues
Fix Blocker/Critical sonar issues in rest-client module https://sonar.onap.org/component_issues?id=org.openecomp.aai%3Arest-client#resolved=false|severities=BLOCKER NullPointerException might be thrown as 'result' is nullable Issue-Id: AAI-394 Change-Id: If52eb1868d68a8b285507845877fa3cc44382aec Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/aai/restclient/client/RestClient.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/org/onap/aai/restclient/client/RestClient.java b/src/main/java/org/onap/aai/restclient/client/RestClient.java
index b782dad..9e74c95 100644
--- a/src/main/java/org/onap/aai/restclient/client/RestClient.java
+++ b/src/main/java/org/onap/aai/restclient/client/RestClient.java
@@ -67,7 +67,7 @@ public class RestClient {
*/
private RestClientBuilder clientBuilder;
- private final ConcurrentMap<String,InitializedClient> CLIENT_CACHE = new ConcurrentHashMap<String,InitializedClient>();
+ private final ConcurrentMap<String,InitializedClient> CLIENT_CACHE = new ConcurrentHashMap<>();
private static final String REST_CLIENT_INSTANCE = "REST_CLIENT_INSTANCE";
/** Standard logger for producing log statements. */
@@ -326,10 +326,14 @@ public class RestClient {
}
// If we've gotten this far, then we failed all of our retries.
+ if (result == null) {
+ result = new OperationResult();
+ }
+
result.setNumRetries(numRetries);
result.setResultCode(504);
- result.setFailureCause(
- "Failed to get a successful result after multiple retries to target server.");
+ result.setFailureCause("Failed to get a successful result after multiple retries to target server.");
+
return result;
}
@@ -568,8 +572,8 @@ public class RestClient {
logger.info(RestClientMsgs.HEALTH_CHECK_SUCCESS, destAppName, url);
return true;
} else {
- logger.error(RestClientMsgs.HEALTH_CHECK_FAILURE, destAppName, url,
- result.getFailureCause());
+ logger.error(RestClientMsgs.HEALTH_CHECK_FAILURE, destAppName, url, result != null ? result.getFailureCause()
+ : null);
return false;
}
} catch (Exception e) {
@@ -594,9 +598,7 @@ public class RestClient {
Map<String, List<String>> headers, MediaType contentType, MediaType responseType) {
WebResource resource = client.resource(url);
- Builder builder = null;
-
- builder = resource.accept(responseType);
+ Builder builder = resource.accept(responseType);
if (contentType != null) {
builder.type(contentType);