Sonar code smell fix.
[dmaap/datarouter.git] / datarouter-node / src / main / java / org / onap / dmaap / datarouter / node / Delivery.java
index 4675081..0326fb0 100644 (file)
@@ -66,7 +66,6 @@ public class Delivery {
         this.config = config;
         Runnable cmon = this::checkconfig;
         config.registerConfigTask(cmon);
-        checkconfig();
     }
 
     /**
@@ -161,14 +160,16 @@ public class Delivery {
             if (sxdir.startsWith(".")) {
                 continue;
             }
-            File sxf = new File(sxbase + "/" + sxdir);
+            File sxf = new File(sxbase + File.separator + sxdir);
             for (String sdir : sxf.list()) {
                 if (!sdir.startsWith(".")) {
                     cleardir(sxbase + "/" + sxdir + "/" + sdir);
                 }
             }
             try {
-                Files.delete(sxf.toPath());  // won't if anything still in it
+                if (sxf.list().length == 0) {
+                    Files.delete(sxf.toPath());  // won't if anything still in it
+                }
             } catch (IOException e) {
                 logger.error("Failed to delete file: " + sxf.getPath(), e);
             }