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

Can't use Optional with List with @QueryParam with reasteasy controller #23898

Closed
Plawn opened this issue Feb 23, 2022 · 2 comments · Fixed by #24055
Closed

Can't use Optional with List with @QueryParam with reasteasy controller #23898

Plawn opened this issue Feb 23, 2022 · 2 comments · Fixed by #24055
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@Plawn
Copy link

Plawn commented Feb 23, 2022

Describe the bug

When using @QueryParam("name") Optional<List> in a resteasy reactive controller, we get an error:

//
Caused by: java.lang.RuntimeException: Failed to find converter for java.util.List 
//

When used without Optional we don't get this error.

This works:

    @GET
    @Path("/table")
    @Transactional
    public Page<Stuff> getStuff(
        @QueryParam("test") final List<Long> ids,
        @BeanParam PageReq page
    ) {
       //
    }

Expected behavior

We can use an Optional<List> in a resteasy reactive controller

Actual behavior

We get a compilation error

How to Reproduce?

  1. create a Quarkus project, with reasteasy-reactive extension
  2. create a controller with the following endpoint
    @GET
    @Path("/table")
    @Transactional
    public Page<Stuff> getStuff(
        @QueryParam("test") final Optional<List<Long>> ids,
        @BeanParam PageReq page
    ) {
       //
    }

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

tested with 2.6.3.Final and tested in 2.7.2.Final

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

No response

Additional information

No response

@Plawn Plawn added the kind/bug Something isn't working label Feb 23, 2022
@Plawn Plawn changed the title Can't use Optional with List with @QueryParam Can't use Optional with List with @QueryParam with reasteasy controller Feb 23, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 23, 2022

/cc @FroMage, @stuartwdouglas

Sgitario added a commit to Sgitario/quarkus that referenced this issue Mar 2, 2022
Support use when using query params with some collections. Example:

```java
@path("/list")
    @get
    public String sayHelloToList(@QueryParam("name") final Optional<List<String>> names) {
        return doSayHelloToCollection(names);
    }
```

fix quarkusio#23898
@Sgitario
Copy link
Contributor

Sgitario commented Mar 2, 2022

fyi: I've proposed a solution for this issue in #24055

Sgitario added a commit to Sgitario/quarkus that referenced this issue Mar 2, 2022
Support use when using query params with some collections. Example:

```java
@path("/list")
    @get
    public String sayHelloToList(@QueryParam("name") final Optional<List<String>> names) {
        return doSayHelloToCollection(names);
    }
```

fix quarkusio#23898
Sgitario added a commit to Sgitario/quarkus that referenced this issue Mar 2, 2022
Support use when using query params with some collections. Example:

```java
@path("/list")
    @get
    public String sayHelloToList(@QueryParam("name") final Optional<List<String>> names) {
        return doSayHelloToCollection(names);
    }
```

fix quarkusio#23898
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Mar 2, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.4.Final Mar 7, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Mar 7, 2022
Support use when using query params with some collections. Example:

```java
@path("/list")
    @get
    public String sayHelloToList(@QueryParam("name") final Optional<List<String>> names) {
        return doSayHelloToCollection(names);
    }
```

fix quarkusio#23898

(cherry picked from commit 9dd7f7b)
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.

4 participants