summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2018-11-13 17:45:43 +0530
committerIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>2018-11-13 17:46:00 +0530
commit458f4be403cea7ae9091cd4ba9bd432c2c941ed8 (patch)
tree8bcb59e69d488695a87e41a71274bcd39a894877 /src/main
parent98849e3f37c5d2e04cc961bc5953e7cd055d4304 (diff)
Sonar Fix: MusicLockingService
Fixed sonar issues/code-smells across this file Issue-ID: MUSIC-178 Change-Id: Iea3dd8daef36ed0ac2f368671e3530cc5962d870 Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/music/lockingservice/MusicLockingService.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/main/java/org/onap/music/lockingservice/MusicLockingService.java b/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
index f9c09338..097055ba 100644
--- a/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
+++ b/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
@@ -52,30 +52,35 @@ public class MusicLockingService implements Watcher {
connectedSignal.await();
zkLockHandle = new ZkStatelessLockService(zk);
} catch (IOException e) {
+ logger.error("Error", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
throw new MusicServiceException("IO Error has occured" + e.getMessage());
} catch (InterruptedException e) {
+ logger.error("Error", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
throw new MusicServiceException("Exception Occured " + e.getMessage());
}
}
- public ZkStatelessLockService getzkLockHandle() {
- return zkLockHandle;
- }
-
public MusicLockingService(String lockServer) {
try {
ZooKeeper zk = new ZooKeeper(lockServer, SESSION_TIMEOUT, this);
connectedSignal.await();
zkLockHandle = new ZkStatelessLockService(zk);
} catch (IOException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
+ logger.error("Error", e);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
}catch( InterruptedException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
- }catch(Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
- }
+ logger.error("Error", e);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+ }catch(Exception e) {
+ logger.error("Error", e);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+ }
+ }
+
+ public ZkStatelessLockService getzkLockHandle() {
+ return zkLockHandle;
}
public void createLockaIfItDoesNotExist(String lockName) {
@@ -98,6 +103,7 @@ public class MusicLockingService implements Watcher {
try{
data = zkLockHandle.getNodeData(lockName);
}catch (Exception ex){
+ logger.error("Error", ex);
logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
}
if(data !=null)
@@ -120,10 +126,13 @@ public class MusicLockingService implements Watcher {
try {
return zkLockHandle.lock(lockName, lockId);
} catch (KeeperException e) {
+ logger.error("Error", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.LOCKINGERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
}catch( InterruptedException e) {
+ logger.error("Error", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
}catch(Exception e) {
+ logger.error("Error", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
}
return false;