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

Injecting HTTP Client into TypedArgumentBinder results in StackOverflowError #10741

Open
musketyr opened this issue Apr 19, 2024 · 4 comments
Open
Labels
type: bug Something isn't working

Comments

@musketyr
Copy link
Contributor

musketyr commented Apr 19, 2024

Expected Behavior

Developer should be able to depend on any bean that is either a HTTP client or injects HTTP client transitively when creating TypedArgumentBinder

Actual Behaviour

When TypedArgumentBinder even transitively depends on any HTTP client then the application won't start at all.

Steps To Reproduce

Use the repo below for reproducer with branch cannot-depend-on-client-from-binder and run FactsControllerTest

  1. create new application with controller method accepting injecting some POJO e.g. CatFact
  2. create HTTP client that fetches the POJO from some REST API, e.g. https://cat-fact.herokuapp.com
  3. create TypedRequestArgumentBinder that is responsible for injecting the POJO
  4. run the application

Environment Information

JDK 21 Zulu

Example Application

https://github.com/musketyr/micronaut-blocking-calls-in-binders-issue/tree/cannot-depend-on-client-from-binder

Version

4.4.0

@sdelamo
Copy link
Collaborator

sdelamo commented Apr 19, 2024

I am unsure about this. I don't think the API TypedArgumentBinder was thought for users to do network requests inside them. I think that logic would be best in a controller method.

@musketyr
Copy link
Contributor Author

at least there should be some sensible warning. it took quite a long time to figure out in the tree of beans what is causing the issues. ideally it should suggest the workaround using Provider<BeanUsingHttpClient>

@yawkat
Copy link
Member

yawkat commented Apr 23, 2024

The reproducer is private, can you please make it public

@musketyr
Copy link
Contributor Author

@yawkat done!

@yawkat yawkat added the type: bug Something isn't working label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

3 participants