AtomicInteger cleanup 06/104606/1
authorPamela Dragosh <pdragosh@research.att.com>
Fri, 27 Mar 2020 18:47:30 +0000 (14:47 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Fri, 27 Mar 2020 18:47:36 +0000 (14:47 -0400)
Per Jim's last comments.

Issue-ID: POLICY-2305
Change-Id: I1bc73dcd264e9a122f6ec0eece08202cbcb3a8e9
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java

index 5d011f0..df968f9 100644 (file)
@@ -370,10 +370,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
      * @param newStatus the new status
      */
     private void handleIdleStatusChange(final SdcReceptionHandlerStatus newStatus) {
-        if (nbOfNotificationsOngoing.get() > 1) {
-            nbOfNotificationsOngoing.decrementAndGet();
-        } else {
-            nbOfNotificationsOngoing.set(0);
+        if (nbOfNotificationsOngoing.getAndUpdate(curval -> Math.max(0, curval - 1)) == 0) {
             sdcReceptionHandlerStatus = newStatus;
         }
     }