Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflowException for Throwable ExceptionMapper #18603

Closed
antonwiens opened this issue Jul 12, 2021 · 9 comments · Fixed by #18613
Closed

StackOverflowException for Throwable ExceptionMapper #18603

antonwiens opened this issue Jul 12, 2021 · 9 comments · Fixed by #18613
Assignees
Labels
area/resteasy-reactive kind/bug Something isn't working
Milestone

Comments

@antonwiens
Copy link

antonwiens commented Jul 12, 2021

Describe the bug

An ServerExceptionMapper for Throwables always throws a StackOverflowException.

Reproducer:

reproducer-cleaned.zip

Just Call the "/hello" Endpoint to trigger the exception.

Version: 2.0.1

Stacktrace:

java.lang.StackOverflowError
	at java.base/java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1541)
	at java.base/java.lang.ClassLoader.getClassLoadingLock(ClassLoader.java:668)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:591)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:397)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:397)
	at acme.ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass.toResponse(ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass.zig:307)
	at acme.ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map.toResponse(ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map.zig:68)
	at acme.ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass.toResponse$$superforward1(ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass.zig:145)
	at acme.ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass$$function$$2.apply(ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass$$function$$2.zig:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at acme.ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass.toResponse(ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass.zig:307)
	at acme.ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map.toResponse(ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map.zig:68)
	at acme.ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass.toResponse$$superforward1(ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass.zig:145)
	at acme.ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass$$function$$2.apply(ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map_Subclass$$function$$2.zig:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
...

EDIT:
I cleaned up the reproducer, because i tested a lot of stuff and left unused extensions in the gradle build file.
Also i changed the target version for kotlin to 11, because i forgot to change it.

@antonwiens antonwiens added the kind/bug Something isn't working label Jul 12, 2021
@gsmet
Copy link
Member

gsmet commented Jul 12, 2021

@antonwiens could you include part of the stacktrace in the description? It's helpful for other users to find similar issues.

@antonwiens
Copy link
Author

@antonwiens could you include part of the stacktrace in the description? It's helpful for other users to find similar issues.

I added one, sry.

@antonwiens
Copy link
Author

@gsmet any chance this will make it for 2.1? this is blocking me from using quarkus 2 unfortunately

@gsmet
Copy link
Member

gsmet commented Jul 12, 2021

@antonwiens so it was working in 1.13 and doesn't work anymore?

@mkouba could you have a look? I'm seeing recursive interceptor calls so I wonder if it could be related to some of the recent work on the subject.

@antonwiens
Copy link
Author

@antonwiens so it was working in 1.13 and doesn't work anymore?

I can say that it was working in 1.10 and in 1.12 for normal resteasy. I don't know about 1.13 and resteasy-reactive, as its the first time i am using it.

@mkouba
Copy link
Contributor

mkouba commented Jul 12, 2021

could you have a look? I'm seeing recursive interceptor calls so I wonder if it could be related to some of the recent work on the subject.

Hm, it looks like the interceptor is associated with a class generated by resteasy reactive:

@Singleton
@Unremovable
public class ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map implements ResteasyReactiveExceptionMapper {
   private final ThrowableExceptionMapper delegate;

   @Inject
   public ThrowableExceptionMapper$GeneratedExceptionHandlerFor$Throwable$OfMethod$map(ThrowableExceptionMapper var1) {
      this.delegate = var1;
   }

   public Response toResponse(Throwable var1) {
      throw (Throwable)(new IllegalStateException("This should never be called"));
   }

   public Response toResponse(Throwable var1, ServerRequestContext var2) {
      return this.toResponse(var1, var2); // <-- This causes an infinite loop!?
   }
}

CC @geoand @FroMage

@geoand
Copy link
Contributor

geoand commented Jul 12, 2021

I'll take a look

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 12, 2021

/cc @FroMage, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jul 12, 2021

#18613 takes care of the issue

geoand added a commit to geoand/quarkus that referenced this issue Jul 12, 2021
geoand added a commit that referenced this issue Jul 12, 2021
Fix Throwable handling in @ServerExceptionMapper
@quarkus-bot quarkus-bot bot added this to the 2.1 - main milestone Jul 12, 2021
@gsmet gsmet modified the milestones: 2.1 - main, 2.0.2.Final Jul 12, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy-reactive kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants