Cancel PDP timers in PAP 67/86667/1
authorJim Hahn <jrh3@att.com>
Tue, 30 Apr 2019 18:39:43 +0000 (14:39 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 30 Apr 2019 18:39:43 +0000 (14:39 -0400)
When a response is received by PAP from a PDP, the associated timer
(and listener) are not being cancelled.  As a result, when the timer
later expired, PAP was re-sending the request.  Modified the code to fix
this.

Change-Id: Id63f76622c01d286c169b618f8369b849ff31085
Issue-ID: POLICY-1715
Signed-off-by: Jim Hahn <jrh3@att.com>
main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java
main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java

index c17d408..1945b32 100644 (file)
@@ -258,6 +258,8 @@ public abstract class RequestImpl implements Request {
                 return;
             }
 
+            svcmgr.stop();
+
             String reason = checkResponse(response);
             if (reason != null) {
                 logger.info("{} PDP data mismatch via {} {}: {}", getName(), infra, topic, reason);
index 2446533..3d90fcb 100644 (file)
@@ -109,6 +109,9 @@ public class RequestImplTest extends CommonRequestBase {
         PdpStateChange msg2 = new PdpStateChange();
         req.reconfigure(msg2, null);
 
+        // should have cancelled the first timer
+        verify(timer).cancel();
+
         // should only be one token in the queue
         QueueToken<PdpMessage> token = queue.poll();
         assertNotNull(token);
@@ -133,6 +136,9 @@ public class RequestImplTest extends CommonRequestBase {
         PdpStateChange msg2 = new PdpStateChange();
         req.reconfigure(msg2, null);
 
+        // should have cancelled the first timer
+        verify(timer).cancel();
+
         // should only be one token in the queue
         QueueToken<PdpMessage> token = queue.poll();
         assertNotNull(token);
@@ -193,6 +199,9 @@ public class RequestImplTest extends CommonRequestBase {
         verify(timers, times(1)).register(any(), any());
         verify(publisher, times(1)).enqueue(any());
         assertNull(queue.poll());
+
+        // should NOT have cancelled the timer
+        verify(timer, never()).cancel();
     }
 
     @Test
@@ -400,6 +409,7 @@ public class RequestImplTest extends CommonRequestBase {
 
         verify(listener).success(PDP1);
         verify(listener, never()).failure(any(), any());
+        verify(timer).cancel();
     }
 
     @Test
@@ -424,6 +434,7 @@ public class RequestImplTest extends CommonRequestBase {
 
         verify(listener, never()).success(any());
         verify(listener).failure(DIFFERENT, "PDP name does not match");
+        verify(timer).cancel();
     }
 
     @Test