This Spring Boot project demonstrates unexpected behavior when annotating a method as both @Timed and @SneakyThrows.
Services SneakyService and TimedSneakyService implement the Consumer interface and process the passed string as JSON. Since the Consumer interface doesn't include an exception, the services use the @SneakyThrows annotation to allow the JsonProcessingException to pass back to the caller. The only difference being TimedSneakyService also annotates accept() with @Timed.
The SneakyServiceTest succeeds. The same tests exist in TimedSneakyServiceTest but
the badJson_throwsJsonProcessingException() test fails with an unexpected
java.lang.reflect.UndeclaredThrowableException
.
Running the tests demonstrates the problem:
mvnw clean test