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

Micronaut 2.0.0.M3 - Circular dependency in case Client usage in HttpClientFilter #3239

Closed
2 of 4 tasks
kbachl opened this issue May 14, 2020 · 1 comment
Closed
2 of 4 tasks
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@kbachl
Copy link

kbachl commented May 14, 2020

Reported as requested by @graemerocher on gitter

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

demo.tar.gz

  1. open skeleton demo app
  2. build and run
  3. open localhost:8080/tst/t1

Error is:
Internal Server Error: Failed to inject value for parameter [interceptors] of class: com.example.JsonTestFilter\n\nMessage: Circular dependency detected\nPath Taken: \nTestController.setClient([JsonTestClient client]) --> new JsonTestClient$Intercepted(BeanContext beanContext,Qualifier qualifier,[Interceptor[] interceptors]) --> new HttpClientIntroductionAdvice(BeanContext beanContext,[RxHttpClientRegistry clientFactory],JsonMediaTypeCodec jsonMediaTypeCodec,List transformers) --> new RxNettyHttpClientRegistry(HttpClientConfiguration defaultHttpClientConfiguration,[HttpClientFilterResolver httpClientFilterResolver],LoadBalancerResolver loadBalancerResolver,NettyClientSslBuilder nettyClientSslBuilder,ThreadFactory threadFactory,MediaTypeCodecRegistry codecRegistry,EventLoopGroupRegistry eventLoopGroupRegistry,EventLoopGroupFactory eventLoopGroupFactory,BeanContext beanContext) --> new DefaultHttpClientFilterResolver(AnnotationMetadataResolver annotationMetadataResolver,[List clientFilters]) --> JsonTestFilter.setClient([JsonTestClient client]

Expected Behaviour

From gitter:
Upgraded a small micronaut-app from 1.3.5 to 2.0.0.M3 yesterday and since then hit by a problem I'm not sure how to solve.
Trouble is i now getting a io.micronaut.context.exceptions.CircularDependencyException: Failed to inject value for parameter [interceptors]
because I need to inject a @client into an HttpClientFilter.... Reason is that I have the need to add a session header and therefore inject the singleton session manager bean into the HttpClientFilter and of course also need to connect to the host to establish the connection, yet I have the @Clientin the session manager bean and our circle is here...
In Micronaut 1.3.5 this was working without problem and I never noticed any trouble, with 2.0.0.M3 I have no idea how to use a HttpClientFilter in case one needs to get SessionDetails from a Client that gets filtered ....

PS: the login-url call is not reacted on by an if statement in the doFilter if that matters

Enclosed example is simplified containing only 3 classes and 1 interface to demo the problem

Environment Information

  • Operating System: Ubuntu 18.04LTS
  • Micronaut Version: 2.0.0.M3
  • JDK Version: 8

Example Application

demo.tar.gz

@graemerocher graemerocher added the type: bug Something isn't working label May 14, 2020
@graemerocher graemerocher added this to the 2.0.0.RC1 milestone May 14, 2020
@graemerocher graemerocher self-assigned this May 21, 2020
@graemerocher
Copy link
Contributor

javax.inject.Provider needs to be used to inject other clients into a client filter. I have documented this with an example.

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
None yet
Development

No branches or pull requests

2 participants