sonar critical for Exception Handling
[dmaap/messagerouter/mirroragent.git] / src / main / java / com / att / nsa / dmaapMMAgent / MirrorMakerAgent.java
index 341e6bd..8f189b3 100644 (file)
@@ -36,6 +36,7 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.Properties;
 
+import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.jasypt.util.text.BasicTextEncryptor;
 
@@ -152,6 +153,7 @@ public class MirrorMakerAgent {
                        }
                        input = new FileInputStream(mmagenthome + "/etc/" + agentName + propName + ".properties");
                } catch (IOException ex) {
+                       logger.error(" IOException will be handled " + ex);
                        try {
                                input = new FileInputStream(mmagenthome + "/etc/" + propName + ".properties");
                                Properties prop = new Properties();
@@ -166,7 +168,7 @@ public class MirrorMakerAgent {
                                prop.store(out, "");
 
                        } catch (Exception e) {
-                               e.printStackTrace();
+                               logger.error("Exception at checkPropertiesFile " +e);
                        }
                } finally {
                        if (input != null) {
@@ -380,7 +382,7 @@ public class MirrorMakerAgent {
                        }
                }
                logger.info("Adding new MirrorMaker:" + newMirrorMaker.name);
-               if (!exists && mirrorMakers != null) {
+               if (exists == false && mirrorMakers != null) {
                        mirrorMakers.getListMirrorMaker().add(newMirrorMaker);
                } else if (exists == false && mirrorMakers == null) {
                        mirrorMakers = new ListMirrorMaker();
@@ -440,6 +442,8 @@ public class MirrorMakerAgent {
                                try {
                                        Thread.sleep(1000);
                                } catch (InterruptedException e) {
+                                       logger.log(Level.WARN, "Interrupted!", e);
+                                       Thread.currentThread().interrupt();
                                }
                        } catch (IOException ex) {
                                ex.printStackTrace();