aboutsummaryrefslogtreecommitdiffstats
path: root/core/core-infrastructure/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-04-06 15:41:28 +0100
committerliamfallon <liam.fallon@est.tech>2020-04-06 18:44:17 +0100
commit69c227a9f1d91268fbd91471b012af38fba8b857 (patch)
tree6d950f8c4f7b54f8348dc7960e982a8dd26feee3 /core/core-infrastructure/src
parente1085f59c1ecd68de574391dc490973abd72a731 (diff)
Fix intermittent unit test failures WebSocket
The Web Socket server is marked as started before the start process has complted. This change fixes that issue. Issue-ID: POLICY-1470 Change-Id: I5b5ef5832893d884a6551b0516df91cb71d6c622 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'core/core-infrastructure/src')
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/server/MessageServerImpl.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/server/MessageServerImpl.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/server/MessageServerImpl.java
index 3844b9254..5b2167e75 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/server/MessageServerImpl.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/server/MessageServerImpl.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ package org.onap.policy.apex.core.infrastructure.messaging.impl.ws.server;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Collection;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.java_websocket.WebSocket;
import org.onap.policy.apex.core.infrastructure.messaging.MessageHolder;
@@ -47,7 +49,7 @@ public class MessageServerImpl<M> extends InternalMessageBusServer<M> {
private final String connectionUri;
// Indicates if the web socket server is started or not
- private boolean isStarted = false;
+ private final AtomicBoolean isStarted = new AtomicBoolean(false);
/**
* Instantiates a new web socket messaging server for Apex.
@@ -73,7 +75,6 @@ public class MessageServerImpl<M> extends InternalMessageBusServer<M> {
public void startConnection() {
// Start reception of connections on the web socket
start();
- isStarted = true;
}
/**
@@ -98,7 +99,7 @@ public class MessageServerImpl<M> extends InternalMessageBusServer<M> {
Thread.currentThread().interrupt();
// This can happen in normal operation so ignore
}
- isStarted = false;
+ isStarted.set(false);
}
/**
@@ -141,11 +142,12 @@ public class MessageServerImpl<M> extends InternalMessageBusServer<M> {
*/
@Override
public boolean isStarted() {
- return isStarted;
+ return isStarted.get();
}
@Override
public void onStart() {
+ isStarted.set(true);
LOGGER.debug("started deployment server on URI: {}", connectionUri);
}
}