summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorThomas Nelson <nelson24@att.com>2019-01-17 20:36:46 +0000
committerGerrit Code Review <gerrit@onap.org>2019-01-17 20:36:46 +0000
commit6148df8619998e1f00c33bfaf112839593dfbe60 (patch)
treec5ba40ede0f2dbfd0a56446a8ec4fb38849ab76f /src/main
parent8555fec5906db3ae50c7c92b522a898746c45ff3 (diff)
parentdc98c95a6d52e537a729484c0be863fb00422017 (diff)
Merge "Fixed sonar issues in ProtocolSupport.java"
Diffstat (limited to 'src/main')
-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();
}
}