diff options
author | Jim Hahn <jrh3@att.com> | 2018-02-19 16:56:06 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2018-02-20 09:59:15 -0500 |
commit | a45f8909871dc1ddb75845f067a602951afc8d11 (patch) | |
tree | fa72aff7ceede971d4e6922f62a503a8ee8924d5 /feature-simulators/src/main/java/org | |
parent | 1708e9a45cb88571613c10b68d392811b2b3f0f4 (diff) |
Sonar fixes to drools-pdp
Fixed most of the instances of the following sonar issues:
Moved array designator
Used diamond operator
Changed System.out/err to use a logger
Changed several Thread.sleep() in test code to a single sleep()
Useless assignments
Replaced comparison with "" to string.isEmpty()
Merged if's
Replaced ArrayList with List in method returns
Reordered type modifiers
Reordered constructor methods
Defined constants for literals, or replaced them with method calls
Removed "throws Xxx" for subclasses of RuntimeException
Combined identical "catch" blocks
Re-interrupted the current thread after catching an InterruptedException
Removed tests against the literal "false"
Fix indentation of new makeTopicOperError() method.
Fix exception variable name in new methods, logNoUebEncoder()
and logNoDmaapEncoder().
Change-Id: Iddae5210553662f733b67333b372dec8c3fe2c94
Issue-ID: POLICY-336
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-simulators/src/main/java/org')
-rw-r--r-- | feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java b/feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java index bdabc6ee..2513a040 100644 --- a/feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java +++ b/feature-simulators/src/main/java/org/onap/policy/drools/simulators/DMaaPSimulatorJaxRs.java @@ -1,8 +1,8 @@ -/*- +/* * ============LICENSE_START======================================================= * feature-simulators * ================================================================================ - * 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. @@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory; @Path("/events") public class DMaaPSimulatorJaxRs { + private static final String NO_DATA_MSG = "No Data"; private static final Map<String, BlockingQueue<String>> queues = new ConcurrentHashMap<>(); private static final Logger logger = LoggerFactory.getLogger(DMaaPSimulatorJaxRs.class); private static int responseCode = 200; @@ -57,7 +58,6 @@ public class DMaaPSimulatorJaxRs { try { httpResponse.flushBuffer(); } catch (IOException e) { - final Logger logger = LoggerFactory.getLogger(DMaaPSimulatorJaxRs.class); logger.error("flushBuffer threw: ", e); return "Got an error"; } @@ -68,14 +68,15 @@ public class DMaaPSimulatorJaxRs { } if (queues.containsKey(topicName)) { BlockingQueue<String> queue = queues.get(topicName); - String response = "No Data"; + String response = NO_DATA_MSG; try { response = queue.poll(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { logger.debug("error in DMaaP simulator", e); + Thread.currentThread().interrupt(); } if (response == null) { - response = "No Data"; + response = NO_DATA_MSG; } return response; } @@ -86,12 +87,13 @@ public class DMaaPSimulatorJaxRs { BlockingQueue<String> queue = queues.get(topicName); String response = queue.poll(); if (response == null) { - response = "No Data"; + response = NO_DATA_MSG; } return response; } } catch (InterruptedException e) { logger.debug("error in DMaaP simulator", e); + Thread.currentThread().interrupt(); } } return "No topic"; |