Merge branch '1.1.x'
This commit is contained in:
commit
c556175381
|
|
@ -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"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue