|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -76,6 +76,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|
|
|
import org.springframework.web.filter.OncePerRequestFilter;
|
|
|
|
import org.springframework.web.filter.OncePerRequestFilter;
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
|
|
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
|
|
|
|
import org.springframework.web.util.NestedServletException;
|
|
|
|
import org.springframework.web.util.NestedServletException;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
@ -188,6 +189,16 @@ public class WebMvcMetricsFilterTests {
|
|
|
|
.tags("exception", "RuntimeException").timer().count()).isEqualTo(1L);
|
|
|
|
.tags("exception", "RuntimeException").timer().count()).isEqualTo(1L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void streamingError() throws Exception {
|
|
|
|
|
|
|
|
MvcResult result = this.mvc.perform(get("/api/c1/streamingError"))
|
|
|
|
|
|
|
|
.andExpect(request().asyncStarted()).andReturn();
|
|
|
|
|
|
|
|
assertThatCode(
|
|
|
|
|
|
|
|
() -> this.mvc.perform(asyncDispatch(result)).andExpect(status().isOk()));
|
|
|
|
|
|
|
|
assertThat(this.registry.get("http.server.requests")
|
|
|
|
|
|
|
|
.tags("exception", "IOException").timer().count()).isEqualTo(1L);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void anonymousError() {
|
|
|
|
public void anonymousError() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -451,6 +462,14 @@ public class WebMvcMetricsFilterTests {
|
|
|
|
throw new RuntimeException("Boom on " + id + "!");
|
|
|
|
throw new RuntimeException("Boom on " + id + "!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/streamingError")
|
|
|
|
|
|
|
|
public ResponseBodyEmitter streamingError() {
|
|
|
|
|
|
|
|
ResponseBodyEmitter emitter = new ResponseBodyEmitter();
|
|
|
|
|
|
|
|
emitter.completeWithError(
|
|
|
|
|
|
|
|
new IOException("error while writing to the response"));
|
|
|
|
|
|
|
|
return emitter;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Timed
|
|
|
|
@Timed
|
|
|
|
@GetMapping("/regex/{id:\\.[a-z]+}")
|
|
|
|
@GetMapping("/regex/{id:\\.[a-z]+}")
|
|
|
|
public String successfulRegex(@PathVariable String id) {
|
|
|
|
public String successfulRegex(@PathVariable String id) {
|
|
|
|