Fix more sonar issues in drools-pdp 70/97770/1
authorJim Hahn <jrh3@att.com>
Wed, 30 Oct 2019 18:47:54 +0000 (14:47 -0400)
committerJim Hahn <jrh3@att.com>
Wed, 30 Oct 2019 22:28:40 +0000 (18:28 -0400)
Sonar issue fixed:
- log or rethrow exception
- empty code block; moved the comment inside the empty "synchronized" block

Change-Id: I55ca87a321b3a1e4079dae6d5a4d44b651cb3086
Issue-ID: POLICY-2203
Signed-off-by: Jim Hahn <jrh3@att.com>
policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java

index c5841b0..8b80738 100644 (file)
@@ -89,6 +89,7 @@ import org.slf4j.LoggerFactory;
         tags = {@Tag(name = "pdp-d-telemetry", description = "Drools PDP Telemetry Operations")})
 public class RestManager {
 
+    private static final String OFFER_FAILED = "{}: cannot offer to topic {} because of {}";
     private static final String CANNOT_PERFORM_OPERATION = "cannot perform operation";
     private static final String NO_FILTERS = " no filters";
     private static final String NOT_FOUND = " not found: ";
@@ -2085,17 +2086,16 @@ public class RestManager {
                     .build();
             }
         } catch (IllegalArgumentException e) {
-            logger.debug("{}: cannot offer to topic {} because of {}", this, topic, e.getMessage(),
-                            e);
+            logger.debug(OFFER_FAILED, this, topic, e.getMessage(), e);
             return Response.status(Response.Status.NOT_FOUND)
                     .entity(new Error(topic + NOT_FOUND_MSG)).build();
         } catch (IllegalStateException e) {
-            logger.debug("{}: cannot offer to topic {} because of {}", this, topic, e.getMessage(),
-                            e);
+            logger.debug(OFFER_FAILED, this, topic, e.getMessage(), e);
             return Response.status(Response.Status.NOT_ACCEPTABLE)
                     .entity(new Error(topic + " not acceptable due to current state"))
                     .build();
         } catch (Exception e) {
+            logger.debug(OFFER_FAILED, this, topic, e.getMessage(), e);
             return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new Error(e.getMessage()))
                             .build();
         }
index c924fd6..757b67f 100644 (file)
@@ -841,8 +841,8 @@ class PolicyEngineManager implements PolicyEngine {
                 logger.warn("{}: abnormal termination - shutdown graceful time period expiration",
                         PolicyEngineManager.this);
             } catch (final InterruptedException e) {
-                /* courtesy to shutdown() to allow it to return */
                 synchronized (PolicyEngineManager.this) {
+                    /* courtesy to shutdown() to allow it to return */
                 }
                 logger.info("{}: finishing a graceful shutdown ", PolicyEngineManager.this, e);
             } finally {