]> source.dussan.org Git - sonarqube.git/commitdiff
Fix two logger calls
authorDaniel Trebbien <dtrebbien@gmail.com>
Mon, 9 Oct 2017 15:54:17 +0000 (10:54 -0500)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 10 Oct 2017 12:23:40 +0000 (14:23 +0200)
One logger call was using incorrect syntax for a formatting anchor
('%s' should be '{}').

The other logger call had three formatting anchors, but only passed two
values.

These issues were found by SLF4J Helper for NetBeans IDE:
http://plugins.netbeans.org/plugin/72557/

server/sonar-main/src/main/java/org/sonar/application/config/FileSystemSettings.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/TimeProfiler.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/TimeProfilerTest.java

index b7953aca498e348a4aa4d668cdcc8d60fb1a4deb..baa056012fe7850609a7cef26d8c7f4cf144831f 100644 (file)
@@ -44,13 +44,13 @@ public class FileSystemSettings implements Consumer<Props> {
   }
 
   private static File ensurePropertyIsAbsolutePath(Props props, String propKey) {
-    File homeDir = props.nonNullValueAsFile(PATH_HOME);
     // default values are set by ProcessProperties
     String path = props.nonNullValue(propKey);
     File d = new File(path);
     if (!d.isAbsolute()) {
+      File homeDir = props.nonNullValueAsFile(PATH_HOME);
       d = new File(homeDir, path);
-      LOG.trace("Overriding property {} from relative path '{}' to absolute path '{}'", path, d.getAbsolutePath());
+      LOG.trace("Overriding property {} from relative path '{}' to absolute path '{}'", propKey, path, d.getAbsolutePath());
       props.set(propKey, d.getAbsolutePath());
     }
     return d;
index efe9fc38e73cf0aa93f1c1466169f1e4f6a0637c..440448794fc4fc7f749bfa1ae54d88245a4b4ae8 100644 (file)
@@ -55,7 +55,7 @@ public class TimeProfiler {
     this.name = name;
     this.start = System.currentTimeMillis();
     if (debug) {
-      logger.debug("%s ...", name);
+      logger.debug("{} ...", name);
     } else {
       logger.info("{}...", name);
     }
index 2786c8ba63d77d438b17c2117db81264a4a5c64e..ddc537947f558189ebfce5d786d07a5ed78e1997 100644 (file)
@@ -38,7 +38,7 @@ public class TimeProfilerTest {
   public void testBasicProfiling() {
     TimeProfiler profiler = new TimeProfiler(logger);
     profiler.start("Cycle analysis");
-    verify(logger).info("Cycle analysis...");
+    verify(logger).info(eq("{}..."), eq("Cycle analysis"));
 
     profiler.stop();
     verify(logger).info(eq("{} done: {} ms"), eq("Cycle analysis"), anyInt());
@@ -52,7 +52,7 @@ public class TimeProfilerTest {
     profiler.stop();
     profiler.stop();
     profiler.stop();
-    verify(logger, times(1)).info(anyString()); // start() executes log() with 1 parameter
+    verify(logger, times(1)).info(anyString(), anyString()); // start() executes log() with 1 parameter
     verify(logger, times(1)).info(anyString(), anyString(), anyInt()); // stop() executes log() with 3 parameters
   }