diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2017-09-15 11:41:47 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2017-09-15 13:57:04 -0400 |
commit | 23808f02e323e745df5749b770cba02fd5c0bfc8 (patch) | |
tree | 33f65a207315397d3560f9b70c8c2c01df07e5e6 /controlloop/common | |
parent | c40726a43c457bed4da442175f5c1b5f4704f57c (diff) |
Fix sonar criticals
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>
Diffstat (limited to 'controlloop/common')
20 files changed, 43 insertions, 41 deletions
diff --git a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java index ffada0a81..bd06ef133 100644 --- a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java +++ b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java @@ -19,19 +19,17 @@ 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; diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java index 0fb25b1bf..fd040494f 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java @@ -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; diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index 503a6fbb3..8849a2351 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -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; diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java index 6be59d668..afb847e09 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java @@ -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; } diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java index dbaf711c4..5ecb44162 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java @@ -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 { diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java index ea966ea55..62ddb0d71 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/PNFTargetLock.java @@ -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(); diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java index 1de105ce4..0a7556bc9 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VMTargetLock.java @@ -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(); diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java index 1350d5c54..b6e49b578 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/impl/VNFTargetLock.java @@ -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(); diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java index 9cb0a220a..00f62cf10 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java @@ -105,6 +105,7 @@ public final class AAINQF199Manager { Thread.sleep(1000); } catch (InterruptedException e) { logger.error(e.getMessage()); + Thread.currentThread().interrupt(); } } diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java index 7b5bcafa7..d455bcf48 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java @@ -20,10 +20,17 @@ 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") diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java index 8ceb067b1..029a4b823 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java @@ -20,9 +20,16 @@ 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; diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java index 86ade6db7..f967414c1 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java @@ -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(); } } diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java index b2535e3af..144b97133 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java @@ -19,7 +19,6 @@ package org.onap.policy.vfc;
import java.io.Serializable;
-import java.time.LocalDateTime;
import com.google.gson.annotations.SerializedName;
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java index a65ad8aac..a4647cb9f 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java @@ -19,7 +19,6 @@ package org.onap.policy.vfc;
import java.io.Serializable;
-import java.time.LocalDateTime;
import com.google.gson.annotations.SerializedName;
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java index f7fc891c0..a19f72bce 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java @@ -19,7 +19,6 @@ package org.onap.policy.vfc;
import java.io.Serializable;
-import java.time.LocalDateTime;
import com.google.gson.annotations.SerializedName;
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java index 6777353a8..a225f2d71 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java @@ -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"); diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java index a45a62dfa..9e3a77a2b 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java @@ -19,7 +19,6 @@ package org.onap.policy.vfc; import java.io.Serializable; -import java.time.LocalDateTime; import com.google.gson.annotations.SerializedName; diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java index 2bdb650ba..fd59325d0 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java @@ -18,19 +18,10 @@ 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); diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java index f0c680784..710ca0165 100644 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java +++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java @@ -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; diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java index 62c2444aa..0fb41ab9b 100644 --- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java +++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java @@ -20,19 +20,19 @@ 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 { |