From 6a9b54b275feff5369419a86997e94d0a95fc48e Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Thu, 7 Jun 2018 16:01:35 +0100 Subject: Fixing Sonar bugs and Vulnerabilities Change-Id: Id5a95f23f1308dbb9f7f0c0f5567e238ecf830af Issue-ID: POLICY-859 Signed-off-by: waqas.ikram --- .../policy/apex/service/engine/engdep/EngDepMessageListener.java | 2 ++ .../onap/policy/apex/service/engine/main/ApexEventMarshaller.java | 4 ++++ .../policy/apex/service/engine/main/ApexEventUnmarshaller.java | 2 ++ .../onap/policy/apex/service/engine/runtime/impl/EngineWorker.java | 2 ++ .../carriertechnology/CarrierTechnologyParametersJSONAdapter.java | 7 ++++--- .../eventprotocol/EventProtocolParametersJSONAdapter.java | 3 ++- 6 files changed, 16 insertions(+), 4 deletions(-) (limited to 'services') diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java index 311e3b660..5c757c6d9 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java @@ -164,6 +164,8 @@ public class EngDepMessageListener implements MessageListener, Runnable } } } catch (final InterruptedException e) { + // restore the interrupt status + Thread.currentThread().interrupt(); LOGGER.debug("message listener execution has been interrupted"); break; } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java index b4ba2ac3e..9904847aa 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java @@ -163,6 +163,8 @@ public class ApexEventMarshaller implements ApexEventListener, Runnable { try { queue.put(apexEvent); } catch (final InterruptedException e) { + // restore the interrupt status + Thread.currentThread().interrupt(); LOGGER.warn("Failed to queue the event: " + apexEvent, e); } } @@ -191,6 +193,8 @@ public class ApexEventMarshaller implements ApexEventListener, Runnable { LOGGER.trace("event sent : " + apexEvent.toString()); } } catch (final InterruptedException e) { + // restore the interrupt status + Thread.currentThread().interrupt(); LOGGER.debug("Thread interrupted, Reason {}", e.getMessage()); break; } catch (final Exception e) { diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java index a9385751e..7b4188ea1 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java @@ -276,6 +276,8 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable { // Pass the event to the activator for forwarding to Apex engineServiceHandler.forwardEvent(apexEvent); } catch (final InterruptedException e) { + // restore the interrupt status + Thread.currentThread().interrupt(); LOGGER.warn("BatchProcessor thread interrupted, Reason {}", e.getMessage()); break; } catch (final Exception e) { diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java index 20f8aaf75..f74c0f47b 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java @@ -649,6 +649,8 @@ final class EngineWorker implements EngineService { try { event = eventProcessingQueue.take(); } catch (final InterruptedException e) { + // restore the interrupt status + Thread.currentThread().interrupt(); LOGGER.debug("Engine {} processing interrupted ", engineWorkerKey); break; } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java index 5aa7d6455..e72a283cd 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java @@ -124,9 +124,10 @@ public class CarrierTechnologyParametersJSONAdapter // Check the carrier technology parameter class if (carrierTechnologyParameterClassName == null || carrierTechnologyParameterClassName.length() == 0) { - final String errorMessage = - "carrier technology \"" + carrierTechnologyLabel + "\" parameter \"" + PARAMETER_CLASS_NAME - + "\" value \"" + classNameJsonPrimitive.getAsString() + "\" invalid in JSON file"; + final String errorMessage = "carrier technology \"" + carrierTechnologyLabel + "\" parameter \"" + + PARAMETER_CLASS_NAME + "\" value \"" + + (classNameJsonPrimitive != null ? classNameJsonPrimitive.getAsString() : "null") + + "\" invalid in JSON file"; LOGGER.warn(errorMessage); throw new ApexParameterRuntimeException(errorMessage); } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java index c880756b3..1f33db6b8 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java @@ -123,7 +123,8 @@ public class EventProtocolParametersJSONAdapter if (eventProtocolParameterClassName == null || eventProtocolParameterClassName.length() == 0) { final String errorMessage = "event protocol \"" + eventProtocolLabel + "\" parameter \"" + PARAMETER_CLASS_NAME + "\" value \"" - + classNameJsonPrimitive.getAsString() + "\" invalid in JSON file"; + + (classNameJsonPrimitive != null ? classNameJsonPrimitive.getAsString() : "null") + + "\" invalid in JSON file"; LOGGER.warn(errorMessage); throw new ApexParameterRuntimeException(errorMessage); } -- cgit 1.2.3-korg