From b8f2cbe2bd9e670b12f5cb4cad277884ba702a11 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 30 Oct 2019 14:47:54 -0400 Subject: Fix more sonar issues in drools-pdp 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 --- .../java/org/onap/policy/drools/server/restful/RestManager.java | 8 ++++---- .../java/org/onap/policy/drools/system/PolicyEngineManager.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java index c5841b06..8b807387 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java @@ -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(); } diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java index c924fd69..757b67fa 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java @@ -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 { -- cgit 1.2.3-korg