summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-05-14 10:59:39 +0900
committerParshad Patel <pars.patel@samsung.com>2019-05-14 10:59:45 +0900
commit67f4f5aead42107dd941772ebb4c3cd4a89424a3 (patch)
treee97ad1dc0241a3b95975613daa0b6cc2e0c61ba9 /src/main/java
parent2757afb4727dd82d834cdd788d10c162fe4b89f5 (diff)
Fix critical sonar issues in messagerouter/mirroragent
Fix Either log or rethrow this exception issue Fix Use a logger to log this exception issue Issue-ID: DMAAP-894 Change-Id: I373a73b789d8b197e475e4fb6990c1b2af3870dc Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java35
-rw-r--r--src/main/java/org/onap/dmaap/mr/dmaapMMAgent/utils/MirrorMakerProcessHandler.java8
2 files changed, 22 insertions, 21 deletions
diff --git a/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java b/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java
index afab7f6..9af3809 100644
--- a/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java
+++ b/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/MirrorMakerAgent.java
@@ -79,8 +79,7 @@ public class MirrorMakerAgent {
try {
agent.checkAgentProcess();
} catch (Exception e) {
-
- e.printStackTrace();
+ logger.error("exception occured in checkAgentProcess ", e);
}
agent.readAgentTopic();
} else {
@@ -95,7 +94,7 @@ public class MirrorMakerAgent {
input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
logger.info("mmagenthome is set :" + mmagenthome + " loading properties at /etc/mmagent.config");
} catch (IOException ex) {
- logger.error(mmagenthome + "/etc/mmagent.config not found.");
+ logger.error(mmagenthome + "/etc/mmagent.config not found.", ex);
return false;
} finally {
if (input != null) {
@@ -112,7 +111,7 @@ public class MirrorMakerAgent {
input = new FileInputStream(kafkahome + "/bin/kafka-run-class.sh");
logger.info("kafkahome is set :" + kafkahome);
} catch (IOException ex) {
- logger.error(kafkahome + "/bin/kafka-run-class.sh not found. Make sure kafka home is set correctly");
+ logger.error(kafkahome + "/bin/kafka-run-class.sh not found. Make sure kafka home is set correctly", ex);
return false;
} finally {
if (input != null) {
@@ -174,7 +173,7 @@ public class MirrorMakerAgent {
try {
input.close();
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("exception occured in checkPropertiesFile ", e);
}
}
if (out != null) {
@@ -269,7 +268,7 @@ public class MirrorMakerAgent {
}
} catch (Exception e) {
- e.printStackTrace();
+ logger.error("exception occured in readAgentTopic ", e);
}
}
@@ -307,13 +306,13 @@ public class MirrorMakerAgent {
out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
mirrorMakerProperties.store(out, "");
} catch (IOException ex) {
- ex.printStackTrace();
+ logger.error("exception occured in createMirrorMaker ", ex);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("exception occured in createMirrorMaker ", e);
}
}
}
@@ -361,13 +360,13 @@ public class MirrorMakerAgent {
} catch (InterruptedException e) {
}
} catch (IOException ex) {
- ex.printStackTrace();
+ logger.error("exception occured in updateMirrorMaker ", ex);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("exception occured in updateMirrorMaker ", e);
}
}
}
@@ -404,13 +403,13 @@ public class MirrorMakerAgent {
} catch (InterruptedException e) {
}
} catch (IOException ex) {
- ex.printStackTrace();
+ logger.error("exception occured in updateWhiteList ", ex);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("exception occured in updateWhiteList ", e);
}
}
}
@@ -439,12 +438,14 @@ public class MirrorMakerAgent {
File file = new File(path);
file.delete();
} catch (Exception ex) {
+ logger.error("exception occured in deleteMirrorMaker ", ex);
}
try {
String path = mmagenthome + "/etc/" + newMirrorMaker.name + "producer" + ".properties";
File file = new File(path);
file.delete();
} catch (Exception ex) {
+ logger.error("exception occured in deleteMirrorMaker ", ex);
}
Gson g = new Gson();
mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
@@ -454,13 +455,13 @@ public class MirrorMakerAgent {
mirrorMakerProperties.store(out, "");
MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
} catch (IOException ex) {
- ex.printStackTrace();
+ logger.error("exception occured in deleteMirrorMaker ", ex);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("exception occured in deleteMirrorMaker ", e);
}
}
}
@@ -479,7 +480,7 @@ public class MirrorMakerAgent {
if (mirrorMakerProperties.getProperty("mirrormakers") == null) {
this.mirrorMakers = new ListMirrorMaker();
ArrayList<MirrorMaker> list = this.mirrorMakers.getListMirrorMaker();
- list = new ArrayList<MirrorMaker>();
+ list = new ArrayList<>();
this.mirrorMakers.setListMirrorMaker(list);
} else {
this.mirrorMakers = g.fromJson(mirrorMakerProperties.getProperty("mirrormakers"),
@@ -496,13 +497,13 @@ public class MirrorMakerAgent {
textEncryptor.setPassword(secret);
this.password = textEncryptor.decrypt(mirrorMakerProperties.getProperty("password"));
} catch (Exception ex) {
- // ex.printStackTrace();
+ logger.error("exception occured in loadProperties ", ex);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
- // e.printStackTrace();
+ logger.error("exception occured in loadProperties ", e);
}
}
}
diff --git a/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/utils/MirrorMakerProcessHandler.java b/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/utils/MirrorMakerProcessHandler.java
index a73ac70..883d151 100644
--- a/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/utils/MirrorMakerProcessHandler.java
+++ b/src/main/java/org/onap/dmaap/mr/dmaapMMAgent/utils/MirrorMakerProcessHandler.java
@@ -135,7 +135,7 @@ public class MirrorMakerProcessHandler {
logger.info("Mirror Maker " + agentname + " Stopped");
} catch (Exception e) {
- e.printStackTrace();
+ logger.error("exception occured in stopMirrorMaker ", e);
}
}
@@ -163,7 +163,7 @@ public class MirrorMakerProcessHandler {
// System.out.println(line);
}
} catch (Exception anExc) {
- anExc.printStackTrace();
+ logger.error("exception occured in startMirrorMaker ", anExc);
}
}
}.start();
@@ -185,7 +185,7 @@ public class MirrorMakerProcessHandler {
// System.out.println(line);
}
} catch (Exception anExc) {
- anExc.printStackTrace();
+ logger.error("exception occured in startMirrorMaker ", anExc);
}
}
}.start();
@@ -194,7 +194,7 @@ public class MirrorMakerProcessHandler {
logger.info("Mirror Maker " + agentName + " Started" + " WhiteListing:" + whitelist);
} catch (Exception e) {
- e.printStackTrace();
+ logger.error("exception occured in startMirrorMaker ", e);
}
}
}