diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2019-12-09 09:34:43 -0600 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-12-10 20:46:09 +0100 |
commit | d1fd889554bccbb50122550899dbb66b90b04f78 (patch) | |
tree | 9cad838366292ee79b77ac3513403f7489b06355 /server/sonar-webserver | |
parent | f86a1094588e4e47b3abf612891af0431653cd0e (diff) | |
download | sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip |
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'server/sonar-webserver')
7 files changed, 11 insertions, 12 deletions
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java index fc765edffee..973a5e0ad5c 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/MasterServletFilter.java @@ -24,6 +24,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import java.io.IOException; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -122,7 +123,7 @@ public class MasterServletFilter implements Filter { private static final class GodFilterChain implements FilterChain { private FilterChain chain; - private List<Filter> filters = Lists.newLinkedList(); + private List<Filter> filters = new LinkedList<>(); private Iterator<Filter> iterator; public GodFilterChain(FilterChain chain) { diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java index b9a0c808d61..ab30626b1de 100644 --- a/server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java +++ b/server/sonar-webserver/src/test/java/org/sonar/server/app/TomcatContextsTest.java @@ -61,7 +61,7 @@ public class TomcatContextsTest { } @Test - public void configure_root_webapp() throws Exception { + public void configure_root_webapp() { props.setProperty("foo", "bar"); StandardContext context = mock(StandardContext.class); when(tomcat.addWebapp(anyString(), anyString())).thenReturn(context); 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 e1b83207b63..f4a4cbf6577 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 @@ -129,7 +129,7 @@ public class MasterServletFilterTest { } @Test - public void display_servlet_filter_patterns_in_INFO_log() throws Exception { + public void display_servlet_filter_patterns_in_INFO_log() { ServletFilter filter = new PatternFilter(UrlPattern.builder().includes("/api/issues").excludes("/batch/projects").build()); FilterConfig config = mock(FilterConfig.class); MasterServletFilter master = new MasterServletFilter(); diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java index 255e97509cc..9d39cc6f885 100644 --- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java +++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java @@ -44,7 +44,7 @@ public class RedirectFilterTest { private RedirectFilter underTest = new RedirectFilter(); @Before - public void setUp() throws Exception { + public void setUp() { when(request.getContextPath()).thenReturn("/sonarqube"); } diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java index 9cb937e245b..c605671fbd5 100644 --- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java +++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/UserSessionFilterTest.java @@ -220,7 +220,7 @@ public class UserSessionFilterTest { } @Test - public void just_for_fun_and_coverage() throws ServletException { + public void just_for_fun_and_coverage() { UserSessionFilter filter = new UserSessionFilter(); filter.init(mock(FilterConfig.class)); filter.destroy(); diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java index d2949b6afc8..5b44991e0ce 100644 --- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java +++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java @@ -53,7 +53,7 @@ public class WebPagesFilterTest { private WebPagesFilter underTest = new WebPagesFilter(webPagesCache); @Before - public void setUp() throws Exception { + public void setUp() { when(servletContext.getContextPath()).thenReturn(TEST_CONTEXT); } @@ -85,7 +85,7 @@ public class WebPagesFilterTest { verifyZeroInteractions(webPagesCache); } - class StringOutputStream extends ServletOutputStream { + static class StringOutputStream extends ServletOutputStream { private final StringBuilder buf = new StringBuilder(); StringOutputStream() { diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java index b10e67ea6fa..f85be9685a4 100644 --- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java +++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebServiceReroutingFilterTest.java @@ -19,9 +19,7 @@ */ package org.sonar.server.platform.web; -import java.io.IOException; import javax.servlet.FilterChain; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; @@ -53,7 +51,7 @@ public class WebServiceReroutingFilterTest { private WebServiceReroutingFilter underTest = new WebServiceReroutingFilter(webServiceEngine); @Before - public void setUp() throws Exception { + public void setUp() { when(request.getContextPath()).thenReturn("/sonarqube"); } @@ -65,7 +63,7 @@ public class WebServiceReroutingFilterTest { } @Test - public void redirect_components_update_key() throws Exception { + public void redirect_components_update_key() { when(request.getServletPath()).thenReturn("/api/components/update_key"); when(request.getMethod()).thenReturn("POST"); @@ -75,7 +73,7 @@ public class WebServiceReroutingFilterTest { } @Test - public void redirect_components_bulk_update_key() throws IOException, ServletException { + public void redirect_components_bulk_update_key() { when(request.getServletPath()).thenReturn("/api/components/bulk_update_key"); when(request.getMethod()).thenReturn("POST"); |