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

[4.x] Undesirable exception: io.helidon.http.RequestException: No entity #8827

Closed
hrstoyanov opened this issue Jun 1, 2024 · 2 comments · Fixed by #8939
Closed

[4.x] Undesirable exception: io.helidon.http.RequestException: No entity #8827

hrstoyanov opened this issue Jun 1, 2024 · 2 comments · Fixed by #8939
Assignees
Labels
4.x Version 4.x enhancement New feature or request P3 webserver

Comments

@hrstoyanov
Copy link
Contributor

This is a continuation from the discussion of #8710

The below code can fail :

ServerRequest req = ...;
var params = eq.content().as(Parameters.class);

io.helidon.http.RequestException: No entity
	at io.helidon.http@4.0.8/io.helidon.http.RequestException$Builder.build(RequestException.java:139)
	at io.helidon.webserver@4.0.8/io.helidon.webserver.http.ErrorHandlers.unhandledError(ErrorHandlers.java:203)
	at io.helidon.webserver@4.0.8/io.helidon.webserver.http.ErrorHandlers.lambda$handleError$1(ErrorHandlers.java:182)

Can we make sure it does not, so devs can write clean functional fluent code? Can we return a Parameters "null object" that will have no params ? See discussion for issue #8710

Environment Details

  • Helidon Version: 4.0.9
  • Helidon SE
  • JDK version: 22.0.1
  • OS: MacOs 14.5
  • Docker version (if applicable):
@m0mus m0mus added enhancement New feature or request P3 webclient 4.x Version 4.x labels Jul 1, 2024
@m0mus m0mus removed the webclient label Jul 1, 2024
@tomas-langer
Copy link
Member

tomas-langer commented Jul 1, 2024

Would this resolve your issue:

Optional<Parameterse> params = eq.content().asOptional(Parameters.class);

Solve your problem? You could then use functional style to resolve the case when the optional is empty (which would be if there is no entity).

@hrstoyanov
Copy link
Contributor Author

@tomas-langer - works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x enhancement New feature or request P3 webserver
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants