You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ro...@apache.org on 2021/05/08 18:32:22 UTC

[felix-dev] 01/01: [FELIX-6409] FileInstall logs useless messages due to incorrect interpolations

This is an automated email from the ASF dual-hosted git repository.

rotty3000 pushed a commit to branch FELIX-6409
in repository https://gitbox.apache.org/repos/asf/felix-dev.git

commit a195e1e308fa58cbddb3d292847450b63eaf24d0
Author: Raymond Augé <ro...@apache.org>
AuthorDate: Sat May 8 10:28:21 2021 -0400

    [FELIX-6409] FileInstall logs useless messages due to incorrect interpolations
    
    Signed-off-by: Raymond Augé <ro...@apache.org>
---
 .../felix/fileinstall/internal/ConfigInstaller.java  | 15 +++++++++------
 .../apache/felix/fileinstall/internal/Watcher.java   | 20 ++++++++++----------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
index 9cd812b..82ed61f 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
@@ -298,11 +298,13 @@ public class ConfigInstaller implements ArtifactInstaller, ConfigurationListener
         {
             ht.put(DirectoryWatcher.FILENAME, toConfigKey(f));
             if (old == null) {
-                Util.log(context, Logger.LOG_INFO, "Creating configuration from " + pid[0]
-                        + (pid[1] == null ? "" : "-" + pid[1]) + ".cfg", null);
+                Util.log(context, Logger.LOG_INFO, "Creating configuration {" + pid[0]
+                        + (pid[1] == null ? "" : "-" + pid[1])
+                        + "} from " + f.getName(), null);
             } else {
-                Util.log(context, Logger.LOG_INFO, "Updating configuration from " + pid[0]
-                        + (pid[1] == null ? "" : "-" + pid[1]) + ".cfg", null);
+                Util.log(context, Logger.LOG_INFO, "Updating configuration {" + pid[0]
+                        + (pid[1] == null ? "" : "-" + pid[1])
+						+ "} from " + f.getName(), null);
             }
             config.update(ht);
             return true;
@@ -324,8 +326,9 @@ public class ConfigInstaller implements ArtifactInstaller, ConfigurationListener
     boolean deleteConfig(File f) throws Exception
     {
         String pid[] = parsePid(f.getName());
-        Util.log(context, Logger.LOG_INFO, "Deleting configuration from " + pid[0]
-                + (pid[1] == null ? "" : "-" + pid[1]) + ".cfg", null);
+        Util.log(context, Logger.LOG_INFO, "Deleting configuration {" + pid[0]
+                + (pid[1] == null ? "" : "-" + pid[1])
+                + "} from " + f.getName(), null);
         Configuration config = getConfiguration(toConfigKey(f), pid[0], pid[1]);
         config.delete();
         return true;
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Watcher.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Watcher.java
index b6de977..6ac203b 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Watcher.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Watcher.java
@@ -71,9 +71,9 @@ public abstract class Watcher implements Closeable {
             }
         }
         if (!Files.exists(root)) {
-            fail("Root path does not exist: " + root);
+            fail("Root path does not exist: %s", root);
         } else if (!Files.isDirectory(root)) {
-            fail("Root path is not a directory: " + root);
+            fail("Root path is not a directory: %s", root);
         }
         if (watcher == null) {
             watcher = watch ? getFileSystem().newWatchService() : null;
@@ -166,7 +166,7 @@ public abstract class Watcher implements Closeable {
             }
             Path dir = keys.get(key);
             if (dir == null) {
-                warn("Could not find key for " + key);
+                warn("Could not find key for %s", key);
                 continue;
             }
 
@@ -178,7 +178,7 @@ public abstract class Watcher implements Closeable {
                 Path name = ev.context();
                 Path child = dir.resolve(name);
 
-                debug("Processing event {} on path {}", kind, child);
+                debug("Processing event %s on path %s", kind, child);
 
                 if (kind == OVERFLOW) {
 //                    rescan();
@@ -211,7 +211,7 @@ public abstract class Watcher implements Closeable {
             // reset key and remove from set if directory no longer accessible
             boolean valid = key.reset();
             if (!valid) {
-                debug("Removing key " + key + " and dir " + dir + " from keys");
+                debug("Removing key %s and dir %s from keys", key, dir);
                 keys.remove(key);
 
                 // all directories are inaccessible
@@ -247,7 +247,7 @@ public abstract class Watcher implements Closeable {
             List<Path> files = new ArrayList<Path>(processedMap.keySet());
             for (Path path : files) {
                 if (!Files.exists(path)) {
-                    debug("File has been deleted: " + path);
+                    debug("File has been deleted: %s", path);
                     processedMap.remove(path);
                     if (isMatchesFile(path)) {
                         onRemove(file);
@@ -262,9 +262,9 @@ public abstract class Watcher implements Closeable {
         if (watcher != null) {
             WatchKey key = path.register(watcher, ENTRY_CREATE, ENTRY_MODIFY, ENTRY_DELETE);
             keys.put(key, path);
-            debug("Watched path " + path + " key " + key);
+            debug("Watched path %s key %s", path, key);
         } else {
-            warn("No watcher yet for path " + path);
+            warn("No watcher yet for path %s", path);
         }
     }
 
@@ -312,8 +312,8 @@ public abstract class Watcher implements Closeable {
      * like spring or blueprint, at least the error message will be clearly shown in the log
      *
      */
-    public void fail(String message) {
-        warn(message);
+    public void fail(String message, Object... args) {
+        warn(message, args);
         throw new IllegalArgumentException(message);
     }