Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 11, 2018
2 parents 61be674 + 9bbec81 commit 0322bbc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Expand Up @@ -47,6 +47,7 @@
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
Expand Down Expand Up @@ -186,7 +187,7 @@ public ServletListenerRegistrationBean<RequestContextListener> requestContextLis
public FilterRegistrationBean<MidPointProfilingServletFilter> midPointProfilingServletFilter() {
FilterRegistrationBean<MidPointProfilingServletFilter> registration = new FilterRegistrationBean<>();
registration.setFilter(new MidPointProfilingServletFilter());
registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
// registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
registration.addUrlPatterns("/*");
return registration;
}
Expand Down Expand Up @@ -251,6 +252,12 @@ public ServletRegistrationBean<StaticWebServlet> staticWebServlet() {
return registration;
}

@Bean
public ErrorPageRegistrar errorPageRegistrar() {
return new MidPointErrorPageRegistrar();
}


@Component
public class ServerCustomization implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {

Expand Down
Expand Up @@ -162,11 +162,6 @@ protected void configure(HttpSecurity http) throws Exception {
}
}

@Bean
public ErrorPageRegistrar errorPageRegistrar() {
return new MidPointErrorPageRegistrar();
}

@Bean
@Override
protected AuthenticationManager authenticationManager() throws Exception {
Expand Down
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.midpoint.util.aspect.ProfilingDataManager;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.catalina.connector.ClientAbortException;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -68,7 +69,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
try {
chain.doFilter(request, response);
} catch (IOException | ServletException | RuntimeException | Error e) {
LOGGER.debug("Encountered exception: {}: {}", e.getClass().getName(), e.getMessage(), e);
logException(e);
throw e;
}

Expand All @@ -85,7 +86,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
try {
chain.doFilter(request, response);
} catch (IOException | ServletException | RuntimeException | Error e) {
LOGGER.debug("Encountered exception: {}: {}", e.getClass().getName(), e.getMessage(), e);
logException(e);
throw e;
}
}
Expand All @@ -99,5 +100,15 @@ private void prepareRequestProfilingEvent(ServletRequest request, long elapsed,
ProfilingDataManager.getInstance().prepareRequestProfilingEvent(event);
}

private void logException(Throwable t) throws IOException, ServletException {
if (t instanceof ClientAbortException) {
if (LOGGER.isDebugEnabled()) {
// client abort exceptions are quite OK as they are not an application/server problem
LOGGER.debug("Encountered exception: {}: {}", t.getClass().getName(), t.getMessage(), t);
}
return;
}

LOGGER.error("Encountered exception: {}: {}", t.getClass().getName(), t.getMessage(), t);
}
}

0 comments on commit 0322bbc

Please sign in to comment.