diff options
author | 2018-06-07 16:01:35 +0100 | |
---|---|---|
committer | 2018-06-08 11:48:06 +0100 | |
commit | 6a9b54b275feff5369419a86997e94d0a95fc48e (patch) | |
tree | 8366bfb005057388b99c5639ed17496c881667f1 /core/core-deployment/src | |
parent | 9289ac0afefe62f6c8e9cebddb611a8571bf5642 (diff) |
Fixing Sonar bugs and Vulnerabilities
Change-Id: Id5a95f23f1308dbb9f7f0c0f5567e238ecf830af
Issue-ID: POLICY-859
Signed-off-by: waqas.ikram <waqas.ikram@ericsson.com>
Diffstat (limited to 'core/core-deployment/src')
2 files changed, 38 insertions, 23 deletions
diff --git a/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.java b/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.java index c2a19a167..5fc7dc8c6 100644 --- a/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.java +++ b/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/DeploymentClient.java @@ -20,8 +20,6 @@ package org.onap.policy.apex.core.deployment; -import com.google.common.eventbus.Subscribe; - import java.net.URI; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -37,10 +35,13 @@ import org.onap.policy.apex.core.protocols.Message; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; +import com.google.common.eventbus.Subscribe; + /** - * The Class DeploymentClient handles the client side of an EngDep communication session with an Apex server. It runs a - * thread to handle message sending and session monitoring. It uses a sending queue to queue messages for sending by the - * client thread and a receiving queue to queue messages received from the Apex engine. + * The Class DeploymentClient handles the client side of an EngDep communication session with an + * Apex server. It runs a thread to handle message sending and session monitoring. It uses a sending + * queue to queue messages for sending by the client thread and a receiving queue to queue messages + * received from the Apex engine. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -90,7 +91,8 @@ public class DeploymentClient implements Runnable { thisThread.setName(DeploymentClient.class.getName() + "-" + host + ":" + port); try { - // Establish a connection to the Apex server for EngDep message communication over Web Sockets + // Establish a connection to the Apex server for EngDep message communication over Web + // Sockets service = factory.createClient(new URI("ws://" + host + ":" + port)); service.addMessageListener(new DeploymentClientListener()); @@ -101,7 +103,6 @@ public class DeploymentClient implements Runnable { LOGGER.error("engine<-->deployment client thread exception", e); return; } - // Loop forever, sending messages as they appear on the queue while (true) { try { @@ -110,6 +111,8 @@ public class DeploymentClient implements Runnable { } catch (final InterruptedException e) { // Message sending has been interrupted, we are finished LOGGER.debug("engine<-->deployment client interrupted"); + // restore the interrupt status + thisThread.interrupt(); break; } } @@ -169,10 +172,11 @@ public class DeploymentClient implements Runnable { } /** - * The listener interface for receiving deploymentClient events. The class that is interested in processing a - * deploymentClient event implements this interface, and the object created with that class is registered with a - * component using the component's {@code addDeploymentClientListener} method. When the deploymentClient event - * occurs, that object's appropriate method is invoked. + * The listener interface for receiving deploymentClient events. The class that is interested in + * processing a deploymentClient event implements this interface, and the object created with + * that class is registered with a component using the component's + * {@code addDeploymentClientListener} method. When the deploymentClient event occurs, that + * object's appropriate method is invoked. * * @see DeploymentClientEvent */ @@ -180,8 +184,9 @@ public class DeploymentClient implements Runnable { /* * (non-Javadoc) * - * @see org.onap.policy.apex.core.infrastructure.messaging.MessageListener#onMessage(org.onap.policy.apex.core. - * infrastructure.messaging.impl.ws.messageblock. MessageBlock) + * @see + * org.onap.policy.apex.core.infrastructure.messaging.MessageListener#onMessage(org.onap. + * policy.apex.core. infrastructure.messaging.impl.ws.messageblock. MessageBlock) */ @Subscribe @Override @@ -192,7 +197,9 @@ public class DeploymentClient implements Runnable { /* * (non-Javadoc) * - * @see org.onap.policy.apex.core.infrastructure.messaging.MessageListener#onMessage(java.lang.String) + * @see + * org.onap.policy.apex.core.infrastructure.messaging.MessageListener#onMessage(java.lang. + * String) */ @Override public void onMessage(final String messageString) { diff --git a/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/EngineServiceFacade.java b/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/EngineServiceFacade.java index d954feaa3..11e870c9c 100644 --- a/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/EngineServiceFacade.java +++ b/core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/EngineServiceFacade.java @@ -50,11 +50,12 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * The Class Deployer deploys an Apex model held as an XML file onto an Apex engine. It uses the EngDep protocol to - * communicate with the engine, with the EngDep protocol being carried on Java web sockets. + * The Class Deployer deploys an Apex model held as an XML file onto an Apex engine. It uses the + * EngDep protocol to communicate with the engine, with the EngDep protocol being carried on Java + * web sockets. * - * This deployer is a simple command line deployer that reads the communication parameters and the location of the XML - * model file as arguments. + * This deployer is a simple command line deployer that reads the communication parameters and the + * location of the XML model file as arguments. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -62,7 +63,8 @@ public class EngineServiceFacade { // Get a reference to the logger private static final XLogger LOGGER = XLoggerFactory.getXLogger(EngineServiceFacade.class); - // The default message timeout and timeout increment (the amount of time between polls) in milliseconds + // The default message timeout and timeout increment (the amount of time between polls) in + // milliseconds private static final int CLIENT_START_WAIT_INTERVAL = 100; private static final int REPLY_MESSAGE_TIMEOUT_DEFAULT = 10000; private static final int REPLY_MESSAGE_TIMEOUT_INCREMENT = 100; @@ -100,7 +102,8 @@ public class EngineServiceFacade { try { LOGGER.debug("handshaking with server {}:{} . . .", hostName, port); - // Use the deployment client to handle the EngDep communication towards the Apex server. It runs a thread to + // Use the deployment client to handle the EngDep communication towards the Apex server. + // It runs a thread to // monitor the session and to send // messages client = new DeploymentClient(hostName, port); @@ -184,7 +187,8 @@ public class EngineServiceFacade { * * @param modelFileName the name of the model file containing the model to deploy * @param ignoreConflicts true if conflicts between context in polices is to be ignored - * @param force true if the model is to be applied even if it is incompatible with the existing model + * @param force true if the model is to be applied even if it is incompatible with the existing + * model * @throws ApexException on Apex errors * @throws IOException on IO exceptions from the operating system */ @@ -215,7 +219,8 @@ public class EngineServiceFacade { * @param modelFileName the name of the model file containing the model to deploy * @param modelInputStream the stream that holds the Apex model * @param ignoreConflicts true if conflicts between context in polices is to be ignored - * @param force true if the model is to be applied even if it is incompatible with the existing model + * @param force true if the model is to be applied even if it is incompatible with the existing + * model * @throws ApexException on model deployment errors */ public void deployModel(final String modelFileName, final InputStream modelInputStream, @@ -238,7 +243,8 @@ public class EngineServiceFacade { * * @param apexPolicyModel the name of the model to deploy * @param ignoreConflicts true if conflicts between context in polices is to be ignored - * @param force true if the model is to be applied even if it is incompatible with the existing model + * @param force true if the model is to be applied even if it is incompatible with the existing + * model * @throws ApexException on model deployment errors */ public void deployModel(final AxPolicyModel apexPolicyModel, final boolean ignoreConflicts, final boolean force) @@ -436,6 +442,8 @@ public class EngineServiceFacade { try { receivedMessage = client.getReceiveQueue().poll(REPLY_MESSAGE_TIMEOUT_INCREMENT, TimeUnit.MILLISECONDS); } catch (final InterruptedException e) { + // restore the interrupt status + Thread.currentThread().interrupt(); LOGGER.warn("reception of response from server interrupted {}:{}", hostName, port, e); throw new ApexDeploymentException( "reception of response from server interrupted " + hostName + ':' + port, e); |