diff options
author | Jim Hahn <jrh3@att.com> | 2020-04-28 16:55:24 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-04-29 10:02:25 -0400 |
commit | ed81ba9cc8e54c3c2d8c70972a6307a1b5bbe86a (patch) | |
tree | 5ba1d466265a6114d3d682694538b87ead120fa6 /main/src/main | |
parent | 0f4acdbe709ec9e96e3984cc4541bce0b4096d4e (diff) |
PAP should discard responses for old requests
This is a more robust solution to the race condition previously
identified with back-to-back deployment requests. The old fix has
been rolled back and replaced with this fix.
Issue-ID: POLICY-2527
Signed-off-by: Jim Hahn <jrh3@att.com>
Change-Id: I2ea93f3a5eaac822abecf5d0745429b95712c861
Diffstat (limited to 'main/src/main')
-rw-r--r-- | main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java | 5 | ||||
-rw-r--r-- | main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java | 12 |
2 files changed, 12 insertions, 5 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java index 53d3fbbd..eaacee9e 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java @@ -80,12 +80,9 @@ public class PdpRequests { } // try to reconfigure an existing request with the new message - // - // don't reconfigure the first request PdpMessage newMessage = request.getMessage(); - int count = 0; for (Request req : requests) { - if (count++ > 0 && req.reconfigure(newMessage)) { + if (req.reconfigure(newMessage)) { return; } } diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java index 03a32557..d1ac3d15 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP PAP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -250,6 +250,16 @@ public abstract class RequestImpl implements Request { return; } + /* + * Note: don't have to verify that getResponse() != null, as this code won't + * even be reached if that's the case. + */ + if (!message.getRequestId().equals(response.getResponse().getResponseTo())) { + logger.info("{} ignore old response via {} {}: {}", getName(), infra, topic, + response.getResponse().getResponseTo()); + return; + } + svcmgr.stop(); String reason = checkResponse(response); |