aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/web/RootFilter.java56
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/web/RootFilterTest.java37
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/web.xml4
3 files changed, 2 insertions, 95 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/web/RootFilter.java b/server/sonar-server/src/main/java/org/sonar/server/platform/web/RootFilter.java
index d1d408c2f1e..45abb4ebfd8 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/web/RootFilter.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/web/RootFilter.java
@@ -20,9 +20,7 @@
package org.sonar.server.platform.web;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableSet;
import java.io.IOException;
-import java.util.Set;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -33,9 +31,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.api.utils.log.Profiler;
import static java.lang.String.format;
@@ -50,26 +46,11 @@ import static java.lang.String.format;
*/
public class RootFilter implements Filter {
- private static final String CONFIG_SEPARATOR = ",";
- private static final String URL_SEPARATOR = "/";
-
- private static final String MESSAGE_WITH_QUERY = "%s %s?%s";
- private static final String MESSAGE_WITHOUT_QUERY = "%s %s";
public static final org.sonar.api.utils.log.Logger Logger = Loggers.get("http");
- private String contextRoot;
- private Set<String> staticResourceDirs;
-
@Override
public void init(FilterConfig filterConfig) throws ServletException {
- contextRoot = filterConfig.getServletContext().getContextPath();
-
- String staticResourcesConfig = filterConfig.getInitParameter("staticDirs");
- if (StringUtils.isNotBlank(staticResourcesConfig)) {
- staticResourceDirs = ImmutableSet.copyOf(staticResourcesConfig.split(CONFIG_SEPARATOR));
- } else {
- staticResourceDirs = ImmutableSet.of();
- }
+ // nothing to do
}
@Override
@@ -78,7 +59,7 @@ public class RootFilter implements Filter {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
try {
- doFilter(new ServletRequestWrapper(httpRequest), httpResponse, chain);
+ chain.doFilter(new ServletRequestWrapper(httpRequest), httpResponse);
} catch (Throwable e) {
Loggers.get(RootFilter.class).error(format("Processing of request %s failed", toUrl(httpRequest)), e);
if (!response.isCommitted()) {
@@ -100,39 +81,6 @@ public class RootFilter implements Filter {
return requestURI + '?' + queryString;
}
- private void doFilter(HttpServletRequest httpRequest, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
- String requestUri = httpRequest.getRequestURI();
- String rootDir = getRootDir(requestUri);
-
- if (staticResourceDirs.contains(rootDir)) {
- // Static resource, not profiled
- chain.doFilter(httpRequest, response);
- } else {
- Profiler profiler = Profiler.createIfDebug(Logger).start();
- try {
- chain.doFilter(httpRequest, response);
- } finally {
- if (profiler.isDebugEnabled()) {
- String queryString = httpRequest.getQueryString();
- String message = format(queryString == null ? MESSAGE_WITHOUT_QUERY : MESSAGE_WITH_QUERY, httpRequest.getMethod(), requestUri, queryString);
- profiler.stopDebug(message);
- }
- }
- }
- }
-
- private String getRootDir(String requestUri) {
- String rootPath = "";
- String localPath = StringUtils.substringAfter(requestUri, contextRoot);
- if (localPath.startsWith(URL_SEPARATOR)) {
- int secondSlash = localPath.indexOf(URL_SEPARATOR, 1);
- if (secondSlash > 0) {
- rootPath = URL_SEPARATOR + localPath.substring(1, secondSlash);
- }
- }
- return rootPath;
- }
-
@Override
public void destroy() {
// Nothing
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/web/RootFilterTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/web/RootFilterTest.java
index 03878774212..a4de39d523a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/web/RootFilterTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/web/RootFilterTest.java
@@ -51,7 +51,6 @@ public class RootFilterTest {
@Before
public void initialize() throws Exception {
FilterConfig filterConfig = mock(FilterConfig.class);
- when(filterConfig.getInitParameter("staticDirs")).thenReturn("/static,/assets");
ServletContext context = mock(ServletContext.class);
when(context.getContextPath()).thenReturn("/context");
when(filterConfig.getServletContext()).thenReturn(context);
@@ -62,21 +61,6 @@ public class RootFilterTest {
}
@Test
- public void should_profile_service_call() throws Exception {
- filter.doFilter(request("POST", "/context/service/call", "param=value"), null, chain);
- }
-
- @Test
- public void should_profile_service() throws Exception {
- filter.doFilter(request("POST", "/context/service", null), null, chain);
- }
-
- @Test
- public void should_profile_context_root_as_slash2() throws Exception {
- filter.doFilter(request("POST", "/context", null), null, chain);
- }
-
- @Test
public void throwable_in_dofilter_is_caught_and_500_error_returned_if_response_is_not_committed() throws Exception {
doThrow(new RuntimeException()).when(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class));
HttpServletResponse response = mockHttpResponse(false);
@@ -95,27 +79,6 @@ public class RootFilterTest {
}
@Test
- public void should_not_profile_non_http_request() throws Exception {
- filter.doFilter(mock(ServletRequest.class), null, chain);
- }
-
- @Test
- public void should_not_profile_static_resource() throws Exception {
- filter.doFilter(request("GET", "/context/static/image.png", null), null, chain);
- }
-
- @Test
- public void should_profile_static_resource_if_no_config() throws Exception {
- FilterConfig filterConfig = mock(FilterConfig.class);
- ServletContext context = mock(ServletContext.class);
- when(context.getContextPath()).thenReturn("/context");
- when(filterConfig.getServletContext()).thenReturn(context);
-
- filter.init(filterConfig);
- filter.doFilter(request("GET", "/context/static/image.png", null), null, chain);
- }
-
- @Test
public void request_used_in_chain_do_filter_is_a_servlet_wrapper_when_static_resource() throws Exception {
filter.doFilter(request("GET", "/context/static/image.png", null), null, chain);
ArgumentCaptor<ServletRequest> requestArgumentCaptor = ArgumentCaptor.forClass(ServletRequest.class);
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/web.xml b/server/sonar-web/src/main/webapp/WEB-INF/web.xml
index 11382a11f5b..865206d2030 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/web.xml
+++ b/server/sonar-web/src/main/webapp/WEB-INF/web.xml
@@ -55,10 +55,6 @@
<filter>
<filter-name>RootFilter</filter-name>
<filter-class>org.sonar.server.platform.web.RootFilter</filter-class>
- <init-param>
- <param-name>staticDirs</param-name>
- <param-value>/images,/javascripts,/stylesheets</param-value>
- </init-param>
</filter>
<filter>
<filter-name>RoutesFilter</filter-name>