aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/logging/PatternLayoutEncoder.java12
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java3
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java12
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/logging/PatternLayoutEncoderTest.java11
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java1
-rw-r--r--server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/analysis/controller/DefaultActiveRulesControllerTest.java3
-rw-r--r--server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/ServletRequest.java8
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/app/NullJarScanner.java2
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java10
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RegisterServletFiltersTest.java2
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java28
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultFilterableIssueTest.java1
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java1
13 files changed, 44 insertions, 50 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/logging/PatternLayoutEncoder.java b/server/sonar-process/src/main/java/org/sonar/process/logging/PatternLayoutEncoder.java
index 8c8ad68ae78..5cee1460358 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/logging/PatternLayoutEncoder.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/logging/PatternLayoutEncoder.java
@@ -21,15 +21,17 @@ package org.sonar.process.logging;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.pattern.DynamicConverter;
import ch.qos.logback.core.pattern.PatternLayoutEncoderBase;
import java.util.Map;
+import java.util.function.Supplier;
public class PatternLayoutEncoder extends PatternLayoutEncoderBase<ILoggingEvent> {
@Override
public void start() {
PatternLayout patternLayout = new PatternLayout();
- patternLayout.getDefaultConverterMap().putAll(getEscapedMessageConverterConfig());
+ patternLayout.getDefaultConverterSupplierMap().putAll(getEscapedMessageConverterConfig());
patternLayout.setContext(context);
patternLayout.setPattern(getPattern());
patternLayout.setOutputPatternAsHeader(outputPatternAsHeader);
@@ -38,11 +40,11 @@ public class PatternLayoutEncoder extends PatternLayoutEncoderBase<ILoggingEvent
super.start();
}
- private static Map<String, String> getEscapedMessageConverterConfig() {
+ private static Map<String, Supplier<DynamicConverter>> getEscapedMessageConverterConfig() {
return Map.of(
- "m", EscapedMessageConverter.class.getName(),
- "msg", EscapedMessageConverter.class.getName(),
- "message", EscapedMessageConverter.class.getName());
+ "m", EscapedMessageConverter::new,
+ "msg", EscapedMessageConverter::new,
+ "message", EscapedMessageConverter::new);
}
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java
index 084169a70ee..36cd7a8e54a 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java
@@ -791,8 +791,7 @@ public class Log4JPropertiesBuilderTest {
{Level.WARN},
{Level.INFO},
{Level.DEBUG},
- {Level.TRACE},
- {Level.ALL}
+ {Level.TRACE}
};
}
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java
index d807d723b7c..9ce425f6aec 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java
@@ -55,7 +55,6 @@ import org.sonar.process.MessageException;
import org.sonar.process.ProcessId;
import org.sonar.process.Props;
-import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.RandomStringUtils.secure;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -175,7 +174,7 @@ public class LogbackHelperTest {
julLogger.severe("Message1");
// JUL bridge has not been initialized, nothing in logs
- assertThat(memoryAppender.getLogs().stream().filter(l -> l.getMessage().equals("Message1")).collect(toList())).isEmpty();
+ assertThat(memoryAppender.getLogs().stream().filter(l -> l.getMessage().equals("Message1")).toList()).isEmpty();
// Enabling JUL bridge
LoggerContextListener propagator = underTest.enableJulChangePropagation(ctx);
@@ -195,7 +194,7 @@ public class LogbackHelperTest {
assertThat(julLogger.isLoggable(java.util.logging.Level.WARNING)).isTrue();
// We are expecting messages from info to severe
- assertThat(memoryAppender.getLogs().stream().filter(l -> l.getMessage().equals("Message2")).collect(toList())).hasSize(6);
+ assertThat(memoryAppender.getLogs().stream().filter(l -> l.getMessage().equals("Message2")).toList()).hasSize(6);
memoryAppender.clear();
ctx.getLogger(logbackRootLoggerName).setLevel(Level.INFO);
@@ -208,7 +207,7 @@ public class LogbackHelperTest {
julLogger.severe("Message3");
// We are expecting messages from finest to severe in TRACE mode
- assertThat(memoryAppender.getLogs().stream().filter(l -> l.getMessage().equals("Message3")).collect(toList())).hasSize(3);
+ assertThat(memoryAppender.getLogs().stream().filter(l -> l.getMessage().equals("Message3")).toList()).hasSize(3);
memoryAppender.clear();
memoryAppender.stop();
@@ -294,8 +293,8 @@ public class LogbackHelperTest {
@Test
public void createRollingPolicy_fail_if_unknown_policy() {
props.set("sonar.log.rollingPolicy", "unknown:foo");
+ LoggerContext ctx = underTest.getRootContext();
try {
- LoggerContext ctx = underTest.getRootContext();
underTest.createRollingPolicy(ctx, props, "sonar");
fail();
} catch (MessageException e) {
@@ -531,8 +530,7 @@ public class LogbackHelperTest {
{Level.WARN},
{Level.INFO},
{Level.DEBUG},
- {Level.TRACE},
- {Level.ALL}
+ {Level.TRACE}
};
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/PatternLayoutEncoderTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/PatternLayoutEncoderTest.java
index be56cd0a3e7..d4602464a33 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/logging/PatternLayoutEncoderTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/logging/PatternLayoutEncoderTest.java
@@ -23,7 +23,6 @@ import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.entry;
public class PatternLayoutEncoderTest {
@@ -39,11 +38,11 @@ public class PatternLayoutEncoderTest {
assertThat(underTest.getLayout())
.isInstanceOf(ch.qos.logback.classic.PatternLayout.class);
- assertThat(((ch.qos.logback.classic.PatternLayout) underTest.getLayout()).getDefaultConverterMap())
- .contains(
- entry("m", EscapedMessageConverter.class.getName()),
- entry("msg", EscapedMessageConverter.class.getName()),
- entry("message", EscapedMessageConverter.class.getName()));
+ assertThat(((ch.qos.logback.classic.PatternLayout) underTest.getLayout()).getDefaultConverterSupplierMap())
+ .containsKeys("m", "msg", "message")
+ .satisfies(m -> assertThat(m.get("m").get()).isInstanceOf(EscapedMessageConverter.class))
+ .satisfies(m -> assertThat(m.get("msg").get()).isInstanceOf(EscapedMessageConverter.class))
+ .satisfies(m -> assertThat(m.get("message").get()).isInstanceOf(EscapedMessageConverter.class));
}
}
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
index 4f973599cc7..a178c609d37 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.user;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
diff --git a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/analysis/controller/DefaultActiveRulesControllerTest.java b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/analysis/controller/DefaultActiveRulesControllerTest.java
index c35ecfda28a..c1e17611b9f 100644
--- a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/analysis/controller/DefaultActiveRulesControllerTest.java
+++ b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/analysis/controller/DefaultActiveRulesControllerTest.java
@@ -26,6 +26,7 @@ import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.server.rule.ActiveRuleRestReponse;
import org.sonar.server.v2.api.analysis.service.ActiveRulesHandler;
+import org.springframework.test.json.JsonCompareMode;
import org.springframework.test.web.servlet.MockMvc;
import static org.mockito.Mockito.mock;
@@ -101,7 +102,7 @@ class DefaultActiveRulesControllerTest {
mockMvc.perform(get(ACTIVE_RULES_ENDPOINT + "?projectKey=someKey"))
.andExpectAll(
status().isOk(),
- content().json(expectedJson, true));
+ content().json(expectedJson, JsonCompareMode.STRICT));
}
}
diff --git a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/ServletRequest.java b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/ServletRequest.java
index 15e1148af39..9fa16ba1002 100644
--- a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/ServletRequest.java
+++ b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/ServletRequest.java
@@ -22,6 +22,8 @@ package org.sonar.server.ws;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.HttpHeaders;
+import jakarta.servlet.AsyncContext;
+import jakarta.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -30,12 +32,10 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.CheckForNull;
-import jakarta.servlet.AsyncContext;
-import jakarta.servlet.http.HttpServletRequest;
+import org.slf4j.LoggerFactory;
import org.sonar.api.impl.ws.PartImpl;
import org.sonar.api.impl.ws.ValidatingRequest;
import org.sonar.api.server.http.HttpRequest;
-import org.slf4j.LoggerFactory;
import org.sonar.server.http.JakartaHttpRequest;
import org.sonarqube.ws.MediaTypes;
@@ -136,7 +136,7 @@ public class ServletRequest extends ValidatingRequest {
@Override
public String toString() {
- StringBuffer url = source.getRequestURL();
+ StringBuilder url = new StringBuilder(source.getRequestURL());
String query = source.getQueryString();
if (query != null) {
url.append("?").append(query);
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/app/NullJarScanner.java b/server/sonar-webserver/src/main/java/org/sonar/server/app/NullJarScanner.java
index a3461ca4e56..333841b13d0 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/app/NullJarScanner.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/app/NullJarScanner.java
@@ -34,7 +34,7 @@ class NullJarScanner implements JarScanner {
@Override
public void scan(JarScanType jarScanType, ServletContext servletContext, JarScannerCallback jarScannerCallback) {
-
+ // doing nothing is fast!
}
@Override
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
index ed311f003e3..e6a3ff55cc4 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
@@ -19,15 +19,14 @@
*/
package org.sonar.server.platform.web;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
import jakarta.servlet.FilterChain;
-import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -52,7 +51,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-public class MasterServletFilterTest {
+class MasterServletFilterTest {
@RegisterExtension
private final LogTesterJUnit5 logTester = new LogTesterJUnit5();
@@ -153,7 +152,6 @@ public class MasterServletFilterTest {
@Test
void display_servlet_filter_patterns_in_INFO_log() {
HttpFilter filter = new PatternFilter(org.sonar.api.web.UrlPattern.builder().includes("/api/issues").excludes("/batch/projects").build());
- FilterConfig config = mock(FilterConfig.class);
MasterServletFilter master = new MasterServletFilter();
master.init(singletonList(filter));
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RegisterServletFiltersTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RegisterServletFiltersTest.java
index d288806b9a2..51410adc042 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RegisterServletFiltersTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RegisterServletFiltersTest.java
@@ -27,7 +27,7 @@ import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-public class RegisterServletFiltersTest {
+class RegisterServletFiltersTest {
@Test
void should_not_fail_if_master_filter_is_not_up() {
MasterServletFilter.setInstance(null);
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java
index 527b031ec41..3664f8c7509 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class StaticResourcesServletTest {
+class StaticResourcesServletTest {
@RegisterExtension
LogTesterJUnit5 logTester = new LogTesterJUnit5();
@@ -94,7 +94,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void return_content_if_exists_in_installed_plugin() throws Exception {
+ void return_content_if_exists_in_installed_plugin() throws Exception {
system.pluginStream = IOUtils.toInputStream("bar", Charset.defaultCharset());
when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
@@ -106,7 +106,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void return_content_of_folder_of_installed_plugin() throws Exception {
+ void return_content_of_folder_of_installed_plugin() throws Exception {
system.pluginStream = IOUtils.toInputStream("bar", Charset.defaultCharset());
when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
@@ -118,7 +118,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void return_content_of_folder_of_installed_core_extension() throws Exception {
+ void return_content_of_folder_of_installed_core_extension() throws Exception {
system.coreExtensionStream = IOUtils.toInputStream("bar", Charset.defaultCharset());
when(coreExtensionRepository.isInstalled("coreext")).thenReturn(true);
@@ -130,7 +130,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void return_content_of_folder_of_installed_core_extension_over_installed_plugin_in_case_of_key_conflict() throws Exception {
+ void return_content_of_folder_of_installed_core_extension_over_installed_plugin_in_case_of_key_conflict() throws Exception {
system.coreExtensionStream = IOUtils.toInputStream("bar of plugin", Charset.defaultCharset());
when(coreExtensionRepository.isInstalled("samekey")).thenReturn(true);
system.coreExtensionStream = IOUtils.toInputStream("bar of core extension", Charset.defaultCharset());
@@ -145,7 +145,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void mime_type_is_set_on_response() throws Exception {
+ void mime_type_is_set_on_response() throws Exception {
system.pluginStream = IOUtils.toInputStream("bar", Charset.defaultCharset());
when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
@@ -157,7 +157,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void return_404_if_resource_not_found_in_installed_plugin() throws Exception {
+ void return_404_if_resource_not_found_in_installed_plugin() throws Exception {
system.pluginStream = null;
when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
@@ -168,7 +168,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void return_404_if_plugin_does_not_exist() throws Exception {
+ void return_404_if_plugin_does_not_exist() throws Exception {
system.pluginStream = null;
when(pluginRepository.hasPlugin("myplugin")).thenReturn(false);
@@ -179,7 +179,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void return_resource_if_exists_in_requested_plugin() throws Exception {
+ void return_resource_if_exists_in_requested_plugin() throws Exception {
system.pluginStream = IOUtils.toInputStream("bar", Charset.defaultCharset());
when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
when(pluginRepository.getPluginInfo("myplugin")).thenReturn(new PluginInfo("myplugin"));
@@ -192,7 +192,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void do_not_fail_nor_log_ERROR_when_response_is_already_committed_and_plugin_does_not_exist() throws Exception {
+ void do_not_fail_nor_log_ERROR_when_response_is_already_committed_and_plugin_does_not_exist() throws Exception {
system.pluginStream = null;
system.isCommitted = true;
when(pluginRepository.hasPlugin("myplugin")).thenReturn(false);
@@ -205,7 +205,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void do_not_fail_nor_log_ERROR_when_sendError_throws_IOException_and_plugin_does_not_exist() throws Exception {
+ void do_not_fail_nor_log_ERROR_when_sendError_throws_IOException_and_plugin_does_not_exist() throws Exception {
system.sendErrorException = new IOException("Simulating sendError throwing IOException");
when(pluginRepository.hasPlugin("myplugin")).thenReturn(false);
@@ -217,7 +217,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void do_not_fail_nor_log_ERROR_when_response_is_already_committed_and_resource_does_not_exist_in_installed_plugin() throws Exception {
+ void do_not_fail_nor_log_ERROR_when_response_is_already_committed_and_resource_does_not_exist_in_installed_plugin() throws Exception {
system.isCommitted = true;
system.pluginStream = null;
when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
@@ -230,7 +230,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void do_not_fail_nor_log_not_attempt_to_send_error_if_ClientAbortException_is_raised() throws Exception {
+ void do_not_fail_nor_log_not_attempt_to_send_error_if_ClientAbortException_is_raised() throws Exception {
system.pluginStreamException = new ClientAbortException("Simulating ClientAbortException");
when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
@@ -243,7 +243,7 @@ public class StaticResourcesServletTest {
}
@Test
- public void do_not_fail_when_response_is_committed_after_other_error() throws Exception {
+ void do_not_fail_when_response_is_committed_after_other_error() throws Exception {
system.isCommitted = true;
system.pluginStreamException = new RuntimeException("Simulating a error");
when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultFilterableIssueTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultFilterableIssueTest.java
index 6145aec1c11..31fa4bd0c3e 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultFilterableIssueTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultFilterableIssueTest.java
@@ -23,7 +23,6 @@ import org.junit.Before;
import org.junit.Test;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
-import org.sonar.scanner.protocol.Constants.Severity;
import org.sonar.scanner.protocol.output.ScannerReport.Issue;
import org.sonar.scanner.protocol.output.ScannerReport.TextRange;
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
index 1a3bd9a9cb7..f45a81cfe08 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
@@ -223,7 +223,6 @@ class DefaultWsClient implements WsClient {
}
@Override
- @Deprecated
public WsConnector wsConnector() {
return wsConnector;
}