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

Resteasy reactive: No proper handling of missing or empty @Produces for Multi results #15638

Closed
michalszynkiewicz opened this issue Mar 11, 2021 · 2 comments · Fixed by #15654
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@michalszynkiewicz
Copy link
Member

more info: https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/html.20web.20requests/near/229859196

Describe the bug
A rest endpoint returning a multi, missing a @Produces annotation results in NullPointerException thrown at runtime.

java.lang.NullPointerException
at org.jboss.resteasy.reactive.server.handlers.MultiResponseHandler.handle(MultiResponseHandler.java:185)
at org.jboss.resteasy.reactive.server.handlers.MultiResponseHandler.handle(MultiResponseHandler.java:16)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:117)
at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:47)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:17)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:7)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder.lambda$start$1(StaticResourcesRecorder.java:62)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:101)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)

Adding the annotation without value produces a different NPE:

java.lang.RuntimeException: java.lang.RuntimeException: Failed to process method org.acme.GreetingResource#io.smallrye.mutiny.Multi<java.util.Map> check(java.lang.String url)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:235)
at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.setupEndpoints(ResteasyReactiveProcessor.java:388)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:920)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.RuntimeException: Failed to process method org.acme.GreetingResource#io.smallrye.mutiny.Multi<java.util.Map> check(java.lang.String url)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:506)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:276)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:206)
... 11 more
Caused by: java.lang.NullPointerException
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.extractProducesConsumesValues(EndpointIndexer.java:622)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.extractProducesConsumesValues(EndpointIndexer.java:611)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:463)
... 13 more

at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:308)
at io.quarkus.runner.bootstrap.AugmentActionImpl.reloadExistingApplication(AugmentActionImpl.java:195)

Expected behavior
Build error

Actual behavior
(Describe the actual behavior clearly and concisely.)

To Reproduce

https://github.com/thomaswue/quarkus-example/blob/4bd0ee66405d26ab7d0bdc36593db68404218324/src/main/java/org/acme/GreetingResource.java

@michalszynkiewicz michalszynkiewicz added the kind/bug Something isn't working label Mar 11, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 11, 2021

/cc @FroMage, @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Mar 11, 2021

Thanks for reporting this.

We definitely need to do something more user friendly

geoand added a commit to geoand/quarkus that referenced this issue Mar 12, 2021
gsmet added a commit that referenced this issue Mar 12, 2021
@quarkus-bot quarkus-bot bot added this to the 1.13 - master milestone Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants