Commit c5561753 authored by Dave Syer's avatar Dave Syer

Merge branch '1.1.x'

parents 6634af6a 2fae4afe
......@@ -93,10 +93,17 @@ public class MetricFilterAutoConfiguration {
int status = getStatus(response);
Object bestMatchingPattern = request
.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
HttpStatus httpStatus = HttpStatus.OK;
try {
httpStatus = HttpStatus.valueOf(status);
}
catch (Exception e) {
// not convertible
}
if (bestMatchingPattern != null) {
suffix = bestMatchingPattern.toString().replaceAll("[{}]", "-");
}
else if (HttpStatus.valueOf(status).is4xxClientError()) {
else if (httpStatus.is4xxClientError()) {
suffix = UNKNOWN_PATH_SUFFIX;
}
String gaugeKey = getKey("response" + suffix);
......
......@@ -239,6 +239,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
public ErrorWrapperResponse(HttpServletResponse response) {
super(response);
this.status = response.getStatus();
}
@Override
......
......@@ -205,6 +205,21 @@ public class ErrorPageFilterTests {
assertTrue(this.response.isCommitted());
}
@Test
public void statusCode() throws Exception {
this.chain = new MockFilterChain() {
@Override
public void doFilter(ServletRequest request, ServletResponse response)
throws IOException, ServletException {
assertThat(((HttpServletResponse) response).getStatus(), equalTo(200));
super.doFilter(request, response);
}
};
this.filter.doFilter(this.request, this.response, this.chain);
assertThat(((HttpServletResponseWrapper) this.chain.getResponse()).getStatus(),
equalTo(200));
}
@Test
public void subClassExceptionError() throws Exception {
this.filter.addErrorPages(new ErrorPage(RuntimeException.class, "/500"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment