aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorWojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com>2023-06-13 14:11:28 +0200
committersonartech <sonartech@sonarsource.com>2023-06-13 20:03:37 +0000
commit6c88709145ecf40500f5600d420e04c537f4c0a0 (patch)
tree5cca9ab49cb7335eb92ffe82025119b3441ac091 /sonar-core
parent64ae11abcdc2117c247a5364f2543144789ab175 (diff)
downloadsonarqube-6c88709145ecf40500f5600d420e04c537f4c0a0.tar.gz
sonarqube-6c88709145ecf40500f5600d420e04c537f4c0a0.zip
[NOJIRA] Remove usage of deprecated Loggers. (#8527)
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsLoader.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/ComponentKeys.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java8
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/PluginInfo.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/MacAddressProvider.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/platform/ComponentKeysTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java12
16 files changed, 44 insertions, 42 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java b/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java
index 5376e9b676a..d9f8c96296c 100644
--- a/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java
+++ b/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java
@@ -28,14 +28,14 @@ import org.sonar.api.SonarRuntime;
import org.sonar.api.config.Configuration;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.AnnotationUtils;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.core.platform.ExtensionContainer;
import static java.util.Objects.requireNonNull;
public abstract class CoreExtensionsInstaller {
- private static final Logger LOG = Loggers.get(CoreExtensionsInstaller.class);
+ private static final Logger LOG = LoggerFactory.getLogger(CoreExtensionsInstaller.class);
private final SonarRuntime sonarRuntime;
private final CoreExtensionRepository coreExtensionRepository;
diff --git a/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsLoader.java b/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsLoader.java
index b1788bfa8eb..4ff57667607 100644
--- a/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsLoader.java
+++ b/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsLoader.java
@@ -23,8 +23,8 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.inject.Inject;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.core.util.stream.MoreCollectors;
import static com.google.common.base.Preconditions.checkState;
@@ -33,7 +33,7 @@ import static com.google.common.base.Preconditions.checkState;
* Load {@link CoreExtension} and register them into the {@link CoreExtensionRepository}.
*/
public class CoreExtensionsLoader {
- private static final Logger LOG = Loggers.get(CoreExtensionsLoader.class);
+ private static final Logger LOG = LoggerFactory.getLogger(CoreExtensionsLoader.class);
private final CoreExtensionRepository coreExtensionRepository;
private final ServiceLoaderWrapper serviceLoaderWrapper;
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
index 37e25d4a7bb..d4acff8aef9 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
@@ -43,8 +43,8 @@ import org.apache.commons.io.IOUtils;
import org.sonar.api.Startable;
import org.sonar.api.utils.SonarException;
import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginRepository;
@@ -52,7 +52,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public class DefaultI18n implements I18n, Startable {
- private static final Logger LOG = Loggers.get(DefaultI18n.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultI18n.class);
private static final String BUNDLE_PACKAGE = "org.sonar.l10n.";
private final PluginRepository pluginRepository;
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ComponentKeys.java b/sonar-core/src/main/java/org/sonar/core/platform/ComponentKeys.java
index 5f3c5d0d012..48cb5b0b5e2 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/ComponentKeys.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/ComponentKeys.java
@@ -23,11 +23,11 @@ import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import org.sonar.core.util.Uuids;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ComponentKeys {
- private static final Logger LOG = Loggers.get(ComponentKeys.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ComponentKeys.class);
private static final Pattern IDENTITY_HASH_PATTERN = Pattern.compile(".+@[a-f0-9]+");
private final Set<Class> objectsWithoutToString = new HashSet<>();
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java b/sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java
index 0937d119ad0..0da6c64a26c 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/PluginClassLoader.java
@@ -28,7 +28,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang.SystemUtils;
import org.sonar.api.Plugin;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.LoggerFactory;
import org.sonar.updatecenter.common.Version;
import static java.util.Collections.singleton;
@@ -95,13 +95,13 @@ public class PluginClassLoader {
// They can't change metadata like ordering strategy or compatibility mode.
if (Strings.isNullOrEmpty(info.getBasePlugin())) {
if (info.isUseChildFirstClassLoader()) {
- Loggers.get(getClass()).warn("Plugin {} [{}] uses a child first classloader which is deprecated", info.getName(), info.getKey());
+ LoggerFactory.getLogger(getClass()).warn("Plugin {} [{}] uses a child first classloader which is deprecated", info.getName(), info.getKey());
}
def.setSelfFirstStrategy(info.isUseChildFirstClassLoader());
Version minSonarPluginApiVersion = info.getMinimalSonarPluginApiVersion();
boolean compatibilityMode = minSonarPluginApiVersion != null && minSonarPluginApiVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0;
if (compatibilityMode) {
- Loggers.get(getClass()).warn("API compatibility mode is no longer supported. In case of error, plugin {} [{}] should package its dependencies.",
+ LoggerFactory.getLogger(getClass()).warn("API compatibility mode is no longer supported. In case of error, plugin {} [{}] should package its dependencies.",
info.getName(), info.getKey());
}
}
@@ -146,7 +146,7 @@ public class PluginClassLoader {
try {
((Closeable) classLoader).close();
} catch (Exception e) {
- Loggers.get(getClass()).error("Fail to close classloader " + classLoader.toString(), e);
+ LoggerFactory.getLogger(getClass()).error("Fail to close classloader " + classLoader.toString(), e);
}
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/PluginInfo.java b/sonar-core/src/main/java/org/sonar/core/platform/PluginInfo.java
index e0d91e48197..ba2616b7860 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/PluginInfo.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/PluginInfo.java
@@ -37,15 +37,15 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.updatecenter.common.PluginManifest;
import org.sonar.updatecenter.common.Version;
import static java.util.Objects.requireNonNull;
public class PluginInfo implements Comparable<PluginInfo> {
- private static final Logger LOGGER = Loggers.get(PluginInfo.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PluginInfo.class);
private static final Joiner SLASH_JOINER = Joiner.on(" / ").skipNulls();
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java b/sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java
index db00c617608..e2d25d8e1ee 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/StartableBeanPostProcessor.java
@@ -20,7 +20,7 @@
package org.sonar.core.platform;
import org.sonar.api.Startable;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
import org.springframework.lang.Nullable;
@@ -48,7 +48,7 @@ public class StartableBeanPostProcessor implements DestructionAwareBeanPostProce
((Startable) bean).stop();
}
} catch (Exception e) {
- Loggers.get(StartableBeanPostProcessor.class)
+ LoggerFactory.getLogger(StartableBeanPostProcessor.class)
.warn("Dispose of component {} failed", bean.getClass().getCanonicalName(), e);
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java b/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
index 85c56de88be..a61aeb5dc5a 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
@@ -42,12 +42,13 @@ import javax.annotation.Nullable;
import javax.inject.Inject;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Configuration;
import org.sonar.api.platform.Server;
import org.sonar.api.utils.HttpDownloader;
import org.sonar.api.utils.SonarException;
-import org.sonar.api.utils.log.Loggers;
import static org.apache.commons.io.FileUtils.copyInputStreamToFile;
import static org.sonar.core.util.FileUtils.deleteQuietly;
@@ -59,6 +60,7 @@ import static org.sonar.core.util.FileUtils.deleteQuietly;
*/
public class DefaultHttpDownloader extends HttpDownloader {
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultHttpDownloader.class);
private final BaseHttpDownloader downloader;
private final Integer readTimeout;
private final Integer connectTimeout;
@@ -253,7 +255,7 @@ public class DefaultHttpDownloader extends HttpDownloader {
* @throws HttpException if HTTP response code > 400
*/
public InputStream getInput() throws IOException {
- Loggers.get(getClass()).debug("Download: " + uri + " (" + getProxySynthesis(uri, ProxySelector.getDefault()) + ")");
+ LOG.debug("Download: {}} ( {} )", uri, getProxySynthesis(uri, ProxySelector.getDefault()));
HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
connection.setRequestMethod(requestMethod);
HttpsTrust.INSTANCE.trust(connection);
diff --git a/sonar-core/src/main/java/org/sonar/core/util/MacAddressProvider.java b/sonar-core/src/main/java/org/sonar/core/util/MacAddressProvider.java
index bce52c68eee..c0a1bb7930f 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/MacAddressProvider.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/MacAddressProvider.java
@@ -26,15 +26,15 @@ import java.security.SecureRandom;
import java.util.Enumeration;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Used by {@link UuidFactoryImpl}. Heavily inspired by https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/common/MacAddressProvider.java
*/
class MacAddressProvider {
- private static final Logger LOGGER = Loggers.get(MacAddressProvider.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(MacAddressProvider.class);
public static final int BYTE_SIZE = 6;
private MacAddressProvider() {
diff --git a/sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java b/sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java
index b909b236398..eb1e9de9a32 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java
@@ -22,8 +22,8 @@ package org.sonar.core.util;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicLong;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Background thread that logs the state of a counter at fixed intervals.
@@ -43,7 +43,7 @@ public class ProgressLogger {
public static ProgressLogger create(Class clazz, AtomicLong counter) {
String threadName = String.format("ProgressLogger[%s]", clazz.getSimpleName());
- Logger logger = Loggers.get(clazz);
+ Logger logger = LoggerFactory.getLogger(clazz);
return new ProgressLogger(threadName, counter, logger);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java b/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
index 1f70143f758..10689e92839 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
@@ -24,7 +24,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.Logger;
+import org.slf4j.Logger;
import org.sonar.api.utils.log.LoggerLevel;
class DefaultProfiler extends Profiler {
diff --git a/sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java b/sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java
index ce593c3b138..567e9b27243 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java
@@ -20,7 +20,7 @@
package org.sonar.core.util.logs;
import javax.annotation.Nullable;
-import org.sonar.api.utils.log.Logger;
+import org.slf4j.Logger;
/**
*
diff --git a/sonar-core/src/test/java/org/sonar/core/platform/ComponentKeysTest.java b/sonar-core/src/test/java/org/sonar/core/platform/ComponentKeysTest.java
index 74e6326b7cb..360402b128e 100644
--- a/sonar-core/src/test/java/org/sonar/core/platform/ComponentKeysTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/platform/ComponentKeysTest.java
@@ -20,7 +20,7 @@
package org.sonar.core.platform;
import org.junit.Test;
-import org.sonar.api.utils.log.Logger;
+import org.slf4j.Logger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.startsWith;
diff --git a/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java b/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
index d4ca9389040..a8978abaa96 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
@@ -26,7 +26,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.slf4j.event.Level;
import org.sonar.api.testfixtures.log.LogTester;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.LoggerFactory;
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,7 +38,7 @@ public class ProgressLoggerTest {
@Test(timeout = 5_000L)
public void log_at_fixed_intervals() {
AtomicLong counter = new AtomicLong(42L);
- ProgressLogger progress = new ProgressLogger("ProgressLoggerTest", counter, Loggers.get(getClass()));
+ ProgressLogger progress = new ProgressLogger("ProgressLoggerTest", counter, LoggerFactory.getLogger(getClass()));
progress.setPeriodMs(1L);
progress.start();
while (logTester.logs(Level.INFO).size()<2) {
diff --git a/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java b/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
index f88bd0ee4f2..a4b58a618b7 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
@@ -29,7 +29,7 @@ import org.junit.runner.RunWith;
import org.slf4j.event.Level;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.LoggerFactory;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
@@ -40,7 +40,7 @@ public class DefaultProfilerTest {
@Rule
public LogTester tester = new LogTester();
- Profiler underTest = Profiler.create(Loggers.get("DefaultProfilerTest"));
+ Profiler underTest = Profiler.create(LoggerFactory.getLogger("DefaultProfilerTest"));
@DataProvider
public static Object[][] logTimeLastValues() {
diff --git a/sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java b/sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java
index c1a5e5999db..a9a524f18b5 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java
@@ -23,7 +23,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
-import org.sonar.api.utils.log.Loggers;
+import org.slf4j.LoggerFactory;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,29 +33,29 @@ public class ProfilerTest {
@Test
public void create() {
- Profiler profiler = Profiler.create(Loggers.get("foo"));
+ Profiler profiler = Profiler.create(LoggerFactory.getLogger("foo"));
assertThat(profiler).isInstanceOf(DefaultProfiler.class);
}
@Test
public void create_null_profiler_if_trace_level_is_disabled() {
tester.setLevel(LoggerLevel.TRACE);
- Profiler profiler = Profiler.createIfTrace(Loggers.get("foo"));
+ Profiler profiler = Profiler.createIfTrace(LoggerFactory.getLogger("foo"));
assertThat(profiler).isInstanceOf(DefaultProfiler.class);
tester.setLevel(LoggerLevel.DEBUG);
- profiler = Profiler.createIfTrace(Loggers.get("foo"));
+ profiler = Profiler.createIfTrace(LoggerFactory.getLogger("foo"));
assertThat(profiler).isInstanceOf(NullProfiler.class);
}
@Test
public void create_null_profiler_if_debug_level_is_disabled() {
tester.setLevel(LoggerLevel.TRACE);
- Profiler profiler = Profiler.createIfDebug(Loggers.get("foo"));
+ Profiler profiler = Profiler.createIfDebug(LoggerFactory.getLogger("foo"));
assertThat(profiler).isInstanceOf(DefaultProfiler.class);
tester.setLevel(LoggerLevel.INFO);
- profiler = Profiler.createIfDebug(Loggers.get("foo"));
+ profiler = Profiler.createIfDebug(LoggerFactory.getLogger("foo"));
assertThat(profiler).isInstanceOf(NullProfiler.class);
}
}