Fix more sonars in pap 77/109677/2
authorJim Hahn <jrh3@att.com>
Tue, 30 Jun 2020 11:31:20 +0000 (07:31 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 30 Jun 2020 11:40:53 +0000 (07:40 -0400)
Somehow missed this sonar on one line of code:
- remove useless assignments

Apparently, sonar only complains about some useless assignments (perhaps
those that do more than copy a constant).  Fixed one about which it did
not complain, which appeared immediately before the one about which it
DID complain.

At one point, sonar complained about creating ArrayLists without
specifying the initial size (when it was known).  It didn't complain
about this one, but went ahead and fixed it anyway.

Issue-ID: POLICY-2679
Change-Id: I270341195634416db1f8152a95a5822c8d505803
Signed-off-by: Jim Hahn <jrh3@att.com>
main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java

index 09e148b..36f25a0 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2020 Nordix Foundation.
+ *  Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -98,11 +99,11 @@ public class PolicyComponentsHealthCheckProvider {
      * @return a pair containing the status and the response
      */
     public Pair<Status, Map<String, Object>> fetchPolicyComponentsHealthStatus() {
-        boolean isHealthy = true;
-        Map<String, Object> result = new HashMap<>();
+        boolean isHealthy;
+        Map<String, Object> result;
 
         // Check remote components
-        List<Callable<Entry<String, Object>>> tasks = new ArrayList<>();
+        List<Callable<Entry<String, Object>>> tasks = new ArrayList<>(clients.size());
 
         for (HttpClient client : clients) {
             tasks.add(() -> new AbstractMap.SimpleEntry<>(client.getName(), fetchPolicyComponentHealthStatus(client)));