Fix sonar criticals 65/12765/1
authorPamela Dragosh <pdragosh@research.att.com>
Fri, 15 Sep 2017 15:41:47 +0000 (11:41 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Fri, 15 Sep 2017 17:57:04 +0000 (13:57 -0400)
Either re-interrupt this method or rethrow Exception
Transient/Serializable issues
Unused imports
logging exceptions

Issue-ID: POLICY-115
Change-Id: I4c8a0c780e2f6c6e8218c1457f18470f7d95919c
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
20 files changed:
controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java
controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java
controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java
controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java
controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java
controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java
controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java
controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java
controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java
controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java

index ffada0a..bd06ef1 100644 (file)
 package org.onap.policy.controlloop.actor.vfc;
 
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.vfc.VFCRequest;
-import org.onap.policy.vfc.VFCHealRequest;
-import org.onap.policy.vfc.VFCHealAdditionalParams;
-import org.onap.policy.vfc.VFCHealActionVmInfo;
 import org.onap.policy.controlloop.ControlLoopOperation;
+import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
 import org.onap.policy.controlloop.policy.Policy;
+import org.onap.policy.vfc.VFCHealActionVmInfo;
+import org.onap.policy.vfc.VFCHealAdditionalParams;
+import org.onap.policy.vfc.VFCHealRequest;
+import org.onap.policy.vfc.VFCRequest;
 
-import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
index 0fb25b1..fd04049 100644 (file)
@@ -60,7 +60,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
        public final UUID requestID;
        
        private String controlLoopResult;
-       private ControlLoopProcessor processor = null;
+       private transient ControlLoopProcessor processor = null;
        private VirtualControlLoopEvent onset;
        private Integer numOnsets = 0;
        private Integer numAbatements = 0;
@@ -70,7 +70,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
        private boolean isActivated = false;
        private LinkedList<ControlLoopOperation> controlLoopHistory = new LinkedList<>();
        private ControlLoopOperationManager currentOperation = null;
-       private TargetLock targetLock = null;
+       private transient TargetLock targetLock = null;
        private static AAIGETVnfResponse vnfResponse = null;
        private static AAIGETVserverResponse vserverResponse = null;
        
index 503a6fb..8849a23 100644 (file)
@@ -71,13 +71,13 @@ public class ControlLoopOperationManager implements Serializable {
        //
        //public final ATTControlLoopEvent onset;
        public final ControlLoopEvent onset;
-       public final Policy policy;
+       public final transient Policy policy;
 
        //
        // Properties used to track the Operation
        //
        private int attempts = 0;
-       private Operation currentOperation = null;
+       private transient Operation currentOperation = null;
        private LinkedList<Operation> operationHistory = new LinkedList<Operation>();
        private PolicyResult policyResult = null;
        private ControlLoopEventManager eventManager = null;
@@ -107,7 +107,7 @@ public class ControlLoopOperationManager implements Serializable {
        }
 
        private String guardApprovalStatus = "NONE";//"NONE", "PERMIT", "DENY"
-       private Object operationRequest;
+       private transient Object operationRequest;
 
        public Object getOperationRequest() {
                return operationRequest;
index 6be59d6..afb847e 100644 (file)
@@ -387,7 +387,7 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
                try {
                        diff = now - dateUtil.init(timeWindow).getMs();
                } catch (Exception ex) {
-                       System.err.println("PIP thread got Exception " + ex.getLocalizedMessage());
+                       logger.error("PIP thread got Exception " + ex);
                        return -1;
                }
 
index dbaf711..5ecb441 100644 (file)
@@ -140,7 +140,7 @@ public class PolicyGuardXacmlHelper {
 
                 } catch (Exception e) {
                                String message = "Parsing Content-Type: " + connection.getContentType() + ", error=" + e.getMessage();
-                               logger.error("{}: callRESTfulPDP threw: ", message);
+                               logger.error("{}: callRESTfulPDP threw: ", message, e);
                        }
 
             } else {
index ea966ea..62ddb0d 100644 (file)
@@ -38,7 +38,7 @@ public class PNFTargetLock implements TargetLock, Serializable {
        private final TargetType        targetType;
        private final String    target;
        private final UUID              requestID;
-       private final LockCallback callback;
+       private final transient LockCallback callback;
 
        public PNFTargetLock (TargetType type, String target, UUID requestID, LockCallback callback) {
                this.lockID = UUID.randomUUID();
index 1de105c..0a7556b 100644 (file)
@@ -37,7 +37,7 @@ public class VMTargetLock implements TargetLock, Serializable {
        private final TargetType        targetType;
        private final String    target;
        private final UUID              requestID;
-       private final LockCallback callback;
+       private final transient LockCallback callback;
 
        public VMTargetLock(TargetType targetType, String target, UUID requestID, LockCallback callback) {
                this.lockID = UUID.randomUUID();
index 1350d5c..b6e49b5 100644 (file)
@@ -38,7 +38,7 @@ public class VNFTargetLock implements TargetLock, Serializable {
        private final TargetType        targetType;
        private final String    target;
        private final UUID              requestID;
-       private final LockCallback callback;
+       private final transient LockCallback callback;
 
        public VNFTargetLock (TargetType type, String target, UUID requestID, LockCallback callback) {
                this.lockID = UUID.randomUUID();
index 9cb0a22..00f62cf 100644 (file)
@@ -105,6 +105,7 @@ public final class AAINQF199Manager {
                                Thread.sleep(1000);
                        } catch (InterruptedException e) {
                                logger.error(e.getMessage());
+                               Thread.currentThread().interrupt();
                        }
 
                }
index 7b5bcaf..d455bcf 100644 (file)
 
 package org.onap.policy.aai;
 
+import java.io.Serializable;
+
 import com.google.gson.annotations.SerializedName;
 
-public class RelatedToPropertyItem {
+public class RelatedToPropertyItem implements Serializable {
 
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 5644372985092588637L;
+       
        @SerializedName("property-key")
        public String propertyKey;
        @SerializedName("property-value")
index 8ceb067..029a4b8 100644 (file)
 
 package org.onap.policy.aai;
 
+import java.io.Serializable;
+
 import com.google.gson.annotations.SerializedName;
 
-public class Relationship {
+public class Relationship implements Serializable {
+       
+       /**
+        * 
+        */
+       private static final long serialVersionUID = -68508443869003054L;
        
        @SerializedName("related-to")
        public String relatedTo;
index 86ade6d..f967414 100644 (file)
@@ -107,6 +107,7 @@ public final class SOManager {
                                logger.error("Failed to deserialize into SOResponse: ", e);
                        } catch (InterruptedException e) {
                                logger.error("Interrupted exception: ", e);
+                               Thread.currentThread().interrupt();
                        }
                }
                
index 6777353..a225f2d 100644 (file)
@@ -107,6 +107,7 @@ public final class VFCManager implements Runnable {
                 logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e);
             } catch (InterruptedException e) {
                 logger.error("Interrupted exception: {}", e.getLocalizedMessage(), e);
+                Thread.currentThread().interrupt();
             }
         } else {
             logger.warn("VFC Heal Restcall failed");
index 2bdb650..fd59325 100644 (file)
 
 package org.onap.policy.vfc;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import org.onap.policy.vfc.VFCRequest;
-import org.onap.policy.vfc.VFCHealRequest;
-import org.onap.policy.vfc.VFCHealAdditionalParams;
-import org.onap.policy.vfc.VFCHealActionVmInfo;
-import org.onap.policy.vfc.VFCResponse;
-import org.onap.policy.vfc.VFCResponseDescriptor;
+import java.util.LinkedList;
+
 import org.junit.Test;
 import org.onap.policy.vfc.util.Serialization;
-import java.util.LinkedList;
-import java.util.List;
 
 public class TestDemo {
 
@@ -75,7 +66,7 @@ public class TestDemo {
         responseDescriptor.errorCode = null;
         responseDescriptor.responseId = "11";
 
-       response.responseDescriptor.responseHistoryList = new LinkedList();
+           response.responseDescriptor.responseHistoryList = new LinkedList<>();
         response.responseDescriptor.responseHistoryList.add(responseDescriptor);
 
         body = Serialization.gsonPretty.toJson(response);
index f0c6807..710ca01 100644 (file)
@@ -493,7 +493,7 @@ public class ControlLoopCompiler implements Serializable{
     
     private static class PolicyNodeWrapper implements NodeWrapper {
         private static final long serialVersionUID = 8170162175653823082L;
-        private Policy policy;
+        private transient Policy policy;
         
         public PolicyNodeWrapper(Policy operPolicy) {
             this.policy = operPolicy;
index 62c2444..0fb41ab 100644 (file)
 
 package org.onap.policy.simulators;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import java.util.HashMap;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.onap.policy.drools.http.server.HttpServletServer;
-import org.onap.policy.vfc.VFCResponse;
-import org.onap.policy.vfc.util.Serialization;
 import org.onap.policy.rest.RESTManager;
 import org.onap.policy.rest.RESTManager.Pair;
+import org.onap.policy.vfc.VFCResponse;
+import org.onap.policy.vfc.util.Serialization;
 
 public class VfcSimulatorTest {