aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorezhil <ezhrajam@in.ibm.com>2018-12-12 17:50:19 +0530
committerEzhilarasi R <ezhrajam@in.ibm.com>2018-12-12 17:15:42 +0000
commitdc98c95a6d52e537a729484c0be863fb00422017 (patch)
treed82f4072590b971b9602fa4e0b5bc9f724fec951
parent0768534363e9e6f2d6efd962fb1af94e5e9c166c (diff)
Fixed sonar issues in ProtocolSupport.java
Fixed Exception issues and logging sonar issues Issue-ID: MUSIC-261 Change-Id: Ie7fffd3ad612d81fad1180cadd24432dd005fd57 Signed-off-by: ezhil <ezhrajam@in.ibm.com>
-rw-r--r--src/main/java/org/onap/music/lockingservice/ProtocolSupport.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java b/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java
index 19f49beb..589e4e57 100644
--- a/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java
+++ b/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -128,19 +129,25 @@ class ProtocolSupport {
try {
return operation.execute();
} catch (KeeperException.SessionExpiredException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.SESSIONEXPIRED+" for: " + zookeeper + " so reconnecting due to: " + e, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.SESSIONEXPIRED+" for: " + zookeeper + " so reconnecting due to: " + e, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED);
throw e;
} catch (KeeperException.ConnectionLossException e) {
if (exception == null) {
exception = e;
}
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.CONNCECTIVITYERROR, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),"Attempt " + i + " failed with connection loss so attempting to reconnect: " + e);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.CONNCECTIVITYERROR, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED);
+ logger.error(EELFLoggerDelegate.errorLogger, e,"Attempt " + i + " failed with connection loss so attempting to reconnect: " + e);
retryDelay(i);
}
}
- throw exception;
+ if(exception == null)
+ {
+ throw new NullPointerException();
+ }
+ else{
+ throw exception;
+ }
}
/**
@@ -148,7 +155,7 @@ class ProtocolSupport {
*
* @param path the lock path
*/
- protected void ensurePathExists(String path) {
+ protected void ensurePathExists(String path) {
ensureExists(path, null, acl, CreateMode.PERSISTENT);
}
@@ -161,7 +168,7 @@ class ProtocolSupport {
* @param flags create mode flags
*/
protected void ensureExists(final String path, final byte[] data, final List<ACL> acl,
- final CreateMode flags) {
+ final CreateMode flags) {
try {
retryOperation(new ZooKeeperOperation() {
public boolean execute() throws KeeperException, InterruptedException {
@@ -174,11 +181,10 @@ class ProtocolSupport {
}
});
} catch (KeeperException e) {
- logger.error("Error", e);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.KEEPERERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.KEEPERERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
} catch (InterruptedException e) {
- logger.error("Error", e);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+
}
}
@@ -201,8 +207,8 @@ class ProtocolSupport {
try {
Thread.sleep(attemptCount * retryDelay);
} catch (InterruptedException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),"Thread failed to sleep: " + e);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e,"Thread failed to sleep: " + e);
Thread.currentThread().interrupt();
}
}