Resteasy Reactive - Arraylist is an Invalid parameter typ
See original GitHub issueDescribe the bug
During the migration from Resteasy Classic to Resteasy Reactive of one of my applications, I got the stacktrace from below during compilation.
I investigated this problem a bit, and found following resource to be the culprit:
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello(@QueryParam("states") ArrayList<Integer> states)
Replacing the ArrayList with a simple java.util.List, the code compiles and I can call the resource. This worked flawlessly with ArrayList in Resteasy Classic.
Expected behavior
Either allow subtypes of the collection interfaces as parameter of rest resources, or document this required migration.
Actual behavior
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.13.0.CR1:build (default) on project rr-list-queryparam: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] [error]: Build step io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor#setupEndpoints threw an exception: java.lang.RuntimeException: java.lang.RuntimeException: Failed to process method org.acme.ReactiveGreetingResource#java.lang.String h
ello(java.util.ArrayList<java.lang.Integer> states)
[ERROR] at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:238)
[ERROR] at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.setupEndpoints(ResteasyReactiveProcessor.java:396)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:920)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR] at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: java.lang.RuntimeException: Failed to process method org.acme.ReactiveGreetingResource#java.lang.String hello(java.util.ArrayList<java.lang.Integer> states)
[ERROR] at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:512)
[ERROR] at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:285)
[ERROR] at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:209)
[ERROR] ... 11 more
[ERROR] Caused by: java.lang.RuntimeException: Invalid parameter type 'java.util.ArrayList<java.lang.Integer>' used on method method java.lang.String hello(java.util.ArrayList<java.lang.Integer> states) on class org.acme.ReactiveGreetingResource
[ERROR] at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.extractParameterInfo(EndpointIndexer.java:899)
[ERROR] at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:407)
[ERROR] ... 13 more
[ERROR] -> [Help 1]
To Reproduce
Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific).
Or attach an archive containing the reproducer to the issue.
Steps to reproduce the behavior:
- Download the reproducer: rr-list-queryparam.zip
- mvn clean install
- Exception from above happens
- Now replace quarkus-resteasy-reactive with quarkus-resteasy
- mvn clean install
- No exception
Environment (please complete the following information):
Output of uname -a
or ver
MSYS_NT-10.0 NANB7NLNVP2 2.10.0(0.325/5/3) 2018-06-13 23:34 x86_64 Msys
Quarkus version or git rev
1.13.0.CR1
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\eclipse\tools\apache-maven\bin.. Java version: 11.0.7, vendor: Azul Systems, Inc., runtime: C:\eclipse\tools\zulu11.39.15-ca-jdk11.0.7-win_x64 Default locale: de_DE, platform encoding: Cp1252 OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (7 by maintainers)
https://quarkus.io/specs/jaxrs/2.1/index.html#resource_field only mentions
List
.I’m not sure why it would be useful to force an implementation class for
List
such asArrayList
.ATM we do inject with
SingletonList
,EmptyList
orArrayList
, so it’s not even as if we always inject anArrayList
.I say let’s leave things as they are for now. Switching to
List
is super easy for users and it’s probably best we don’t overcommit to such details that could perhaps could back to bite us in the future