quarkus: Inconsistent error logging of thrown exceptions in quarkus-resteasy-reactive-jackson

Describe the bug

Exceptions thrown during REST requests with the quarkus-resteasy-reactive-jackson server are inconsistent.

  • Unchecked exceptions are logged twice
  • Checked exceptions are logged once
  • WebApplicationExceptions are not logged at all

With quarkus-resteasy-jackson, the classic REST server, all types of exceptions were logged once.

If I add a ExceptionMapper<WebApplicationException> or @ServerExceptionMapper then I can make a mapper that logs the WebApplicationException. However, this does not work if the WebApplicationException was thrown from a ContainerRequestFilter with a response. Odly enough it works if you throw a WebApplicationException without providing a response:

Response response = Response.status(500).entity("WebApplicationException with responsefrom container request filter").build();
throw new WebApplicationException(response);

Will not produce a log from the ExceptionMapper<WebApplicationException> , whereas:

throw new WebApplicationException("WebApplicationException from container request filter");

will.

Expected behavior

Same behaviour as with RestEasy Classic: Each type of exception is logged exactly once.

Actual behavior

Unchecked exceptions are logged twice

2023-03-17 14:07:01,604 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /unchecked failed, error id: e84f0101-8ca0-413e-926c-ddc56c2fda93-4: java.lang.RuntimeException: unchecked exception
	at org.acme.ExceptionResource.uncheckedException(ExceptionResource.java:16)
	at org.acme.ExceptionResource$quarkusrestinvoker$uncheckedException_55aaa27236a8cdedd4b721513153332cc8d64044.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:114)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)

2023-03-17 14:07:01,605 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (executor-thread-0) Request failed: java.lang.RuntimeException: unchecked exception
	at org.acme.ExceptionResource.uncheckedException(ExceptionResource.java:16)
	at org.acme.ExceptionResource$quarkusrestinvoker$uncheckedException_55aaa27236a8cdedd4b721513153332cc8d64044.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:114)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)

Checked exceptions are logged once

2023-03-17 14:06:57,104 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (executor-thread-0) Request failed: java.io.IOException: checked exception
	at org.acme.ExceptionResource.checkedException(ExceptionResource.java:26)
	at org.acme.ExceptionResource$quarkusrestinvoker$checkedException_780ec08352b2210b33877338dd8e247443b2486e.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:114)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)

WebApplicationExceptions are not logged at all

Nothing to show here 😃

How to Reproduce?

I’ve added a reproducer with examples here: https://github.com/AndreasPetersen/quarkus-resteasy-reactive-error-logging

It contains three REST endpoints, one for each case. In addition, there is a ExceptionMapper that you can activate by adding @Provider on the class. Likewise, there is are some ContainerRequestFilters throwing exceptions that can be activated by adding @Provider as well.

Output of uname -a or ver

Microsoft Windows [Version 10.0.19044.2604]

Output of java -version

openjdk version “17.0.2” 2022-01-18 OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8) OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.4

Build tool (ie. output of mvnw --version or gradlew --version)

Welcome to Gradle 8.0.2!

Here are the highlights of this release:

  • Improvements to the Kotlin DSL
  • Fine-grained parallelism from the first build with configuration cache
  • Configurable Gradle user home cache cleanup

For more details see https://docs.gradle.org/8.0.2/release-notes.html


Gradle 8.0.2

Build time: 2023-03-03 16:41:37 UTC Revision: 7d6581558e226a580d91d399f7dfb9e3095c2b1d

Kotlin: 1.8.10 Groovy: 3.0.13 Ant: Apache Ant™ version 1.10.11 compiled on July 10 2021 JVM: 11.0.17 (Eclipse Adoptium 11.0.17+8) OS: Windows 10 10.0 amd64

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Correct

When a Response is provided, it signals that the user has provided the whole response (which recall is the whole idea behind an ExceptionMapper).