From 01a357b4e27480844686eb83ef81809a28056e41 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 26 Oct 2018 10:10:28 -0400 Subject: Fix random failures in ManualClientEndTest Don't know if this is the cause of the intermittent failures, but it could be, and it is certainly a bug: the classes manipulate data, that isn't marked volatile, from more than one thread at a time. Updated licenses. Change-Id: Ifca84cf8f915ec703a9ce8980db2475dacf97980 Issue-ID: POLICY-1092 Signed-off-by: Jim Hahn --- .../java/org/onap/policy/std/AutoClientEnd.java | 24 +++++++++++----------- .../java/org/onap/policy/std/ManualClientEnd.java | 12 +++++------ 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'PolicyEngineAPI/src/main/java') diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientEnd.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientEnd.java index aabda96c8..342af2c0f 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientEnd.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientEnd.java @@ -35,18 +35,18 @@ import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.xacml.api.XACMLErrorConstants; public class AutoClientEnd extends WebSocketClient { - private static StdPDPNotification notification = null; - private static StdPDPNotification oldNotification = null; - private static AutoClientEnd client = null; - private static NotificationScheme scheme = null; - private static NotificationHandler handler = null; - private static String url = null; - private static boolean status = false; - private static boolean stop = false; - private static boolean error = false; - private static boolean restartNeeded = false; - private static ScheduledExecutorService restartExecutorService = null; - private static Logger logger = FlexLogger.getLogger(AutoClientEnd.class.getName()); + private static volatile StdPDPNotification notification = null; + private static volatile StdPDPNotification oldNotification = null; + private static volatile AutoClientEnd client = null; + private static volatile NotificationScheme scheme = null; + private static volatile NotificationHandler handler = null; + private static volatile String url = null; + private static volatile boolean status = false; + private static volatile boolean stop = false; + private static volatile boolean error = false; + private static volatile boolean restartNeeded = false; + private static volatile ScheduledExecutorService restartExecutorService = null; + private static final Logger logger = FlexLogger.getLogger(AutoClientEnd.class.getName()); private AutoClientEnd(URI serverUri) { super(serverUri); diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEnd.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEnd.java index 778acd716..b274fa1a9 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEnd.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEnd.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * PolicyEngineAPI * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 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. @@ -33,11 +33,11 @@ import org.onap.policy.std.StdPDPNotification; import org.onap.policy.xacml.api.XACMLErrorConstants; public class ManualClientEnd extends WebSocketClient { - private static CountDownLatch latch; - private static StdPDPNotification notification = null; - private static String resultJson = null; - private static Logger logger = FlexLogger.getLogger(ManualClientEnd.class.getName()); - private static ManualClientEnd client; + private static volatile CountDownLatch latch; + private static volatile StdPDPNotification notification = null; + private static volatile String resultJson = null; + private static final Logger logger = FlexLogger.getLogger(ManualClientEnd.class.getName()); + private static volatile ManualClientEnd client; public ManualClientEnd(URI serverUri) { super(serverUri); -- cgit 1.2.3-korg