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

Access to request().query().get() raises UnsupportedOperationException #7867

Closed
io7m opened this issue Oct 20, 2023 · 0 comments · Fixed by #7869
Closed

Access to request().query().get() raises UnsupportedOperationException #7867

io7m opened this issue Oct 20, 2023 · 0 comments · Fixed by #7869
Assignees
Labels
4.x Version 4.x bug Something isn't working
Milestone

Comments

@io7m
Copy link

io7m commented Oct 20, 2023

Environment Details

  • Helidon Version: 4.0.0-RC1
  • Helidon SE
  • JDK version:
openjdk version "21" 2023-09-19
OpenJDK Runtime Environment (build 21+35)
OpenJDK 64-Bit Server VM (build 21+35, mixed mode, sharing)
  • OS: Linux

Problem Description

The Javadoc for the io.helidon.common.uri.UriQuery interface's get method says:

    /**
     * Get the first value.
     *
     * @param name name of the parameter
     * @return first value
     * @throws NoSuchElementException in case the name is not present
     */
    String get(String name) throws NoSuchElementException;

Unfortunately, the implementation of UriQueryEmpty has:

  @Override
  public String get(String name) {
      throw new UnsupportedOperationException("Empty query");
  }

This means you'll get an UnsupportedOperationException instead of the expected NoSuchElementException if you're trying to get a parameter from a query that didn't contain any parameters.

Steps to reproduce

Just try calling ServerRequest.query().get("x") for any incoming query that has no parameters.

@romain-grecourt romain-grecourt added this to the 4.0.0 milestone Oct 20, 2023
@romain-grecourt romain-grecourt added bug Something isn't working 4.x Version 4.x labels Oct 20, 2023
@romain-grecourt romain-grecourt self-assigned this Oct 20, 2023
romain-grecourt added a commit to romain-grecourt/helidon that referenced this issue Oct 20, 2023
Update UriQueryEmpty to throw NoSuchElementException instead of UnsupportedOperationException as documented.

Fixes helidon-io#7867
@romain-grecourt romain-grecourt linked a pull request Oct 20, 2023 that will close this issue
barchetta pushed a commit that referenced this issue Oct 20, 2023
Update UriQueryEmpty to throw NoSuchElementException instead of UnsupportedOperationException as documented.

Fixes #7867
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants