From 6665b07ea30db54331b3bf3a9cbedb6aa629e35d Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Thu, 2 Apr 2020 09:57:52 -0400 Subject: Synchronize methods for rules Added "synchronized" to a few more methods in the event manager class, just to be safe, as they view/modify data that may be viewed/modified by other threads. Issue-ID: POLICY-2385 Signed-off-by: Jim Hahn Change-Id: Ia8404fd3fd53b0de95f939dfff2088867e0f3b24 --- .../eventmanager/ControlLoopEventManager2.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'controlloop') diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java index 05563ca8d..cc54b73be 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java @@ -249,7 +249,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { /** * Starts the next step, whatever that may be. */ - public void nextStep() { + public synchronized void nextStep() { if (!isActive()) { return; } @@ -280,7 +280,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { * * @return {@code true} if the manager is still active, {@code false} otherwise */ - public boolean isActive() { + public synchronized boolean isActive() { return (createdByThisJvmInstance && finalResult == null); } @@ -355,7 +355,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { /** * Cancels the current operation and frees all locks. */ - public void destroy() { + public synchronized void destroy() { ControlLoopOperationManager2 oper = currentOperation.get(); if (oper != null) { oper.cancel(); @@ -376,7 +376,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { * * @return a new notification */ - public VirtualControlLoopNotification makeNotification() { + public synchronized VirtualControlLoopNotification makeNotification() { VirtualControlLoopNotification notif = new VirtualControlLoopNotification(context.getEvent()); notif.setNotification(ControlLoopNotificationType.OPERATION); notif.setFrom("policy"); @@ -400,7 +400,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { * @param event the event * @return the status */ - public NewEventStatus onNewEvent(VirtualControlLoopEvent event) { + public synchronized NewEventStatus onNewEvent(VirtualControlLoopEvent event) { try { checkEventSyntax(event); @@ -446,7 +446,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { * @param event the event syntax * @throws ControlLoopException if an error occurs */ - public void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException { + protected void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException { validateStatus(event); if (StringUtils.isBlank(event.getClosedLoopControlName())) { throw new ControlLoopException("No control loop name"); @@ -514,7 +514,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { * @return true if the control loop is disabled, false * otherwise */ - public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) { + private static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) { Map aai = event.getAai(); return (isAaiTrue(aai.get(VSERVER_IS_CLOSED_LOOP_DISABLED)) || isAaiTrue(aai.get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)) @@ -528,7 +528,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { * @return {@code true} if the provisioning status is neither ACTIVE nor {@code null}, * {@code false} otherwise */ - protected static boolean isProvStatusInactive(VirtualControlLoopEvent event) { + private static boolean isProvStatusInactive(VirtualControlLoopEvent event) { Map aai = event.getAai(); return !(PROV_STATUS_ACTIVE.equals(aai.getOrDefault(VSERVER_PROV_STATUS, PROV_STATUS_ACTIVE)) && PROV_STATUS_ACTIVE.equals(aai.getOrDefault(GENERIC_VNF_PROV_STATUS, PROV_STATUS_ACTIVE))); @@ -541,7 +541,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { * @return the boolean value represented by the field value, or {@code false} if the * value is {@code null} */ - protected static boolean isAaiTrue(String aaiValue) { + private static boolean isAaiTrue(String aaiValue) { return (aaiValue != null && TRUE_VALUES.contains(aaiValue.toLowerCase())); } -- cgit 1.2.3-korg