Merge branch '1.1.x'

This commit is contained in:
Dave Syer 2014-08-13 08:15:59 -07:00
commit c556175381
3 changed files with 24 additions and 1 deletions

View File

@ -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);

View File

@ -239,6 +239,7 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
public ErrorWrapperResponse(HttpServletResponse response) {
super(response);
this.status = response.getStatus();
}
@Override

View File

@ -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"));