-
Notifications
You must be signed in to change notification settings - Fork 754
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
FeignClient gets created too early for contract tests #441
Comments
Feign Clients have timing issues. You can not use them in constructors or post construct. I'm not sure there's anything we can do |
I don't understand your answer. I am autowiring a FeignClient in my test class. That FeignClient has an a url property that gets evaluated before the test class annotations are fully processed (that's why I cannot connect to the test wiremock). |
I also hit the same problem - twice. To give a bit of a background, my team runs a number of projects. Each has Cucumber component tests that use Feign clients. So basically, we inject Feign clients into the compoent tests to call the service being tested. The services itself uses Feign clients to call other services, which in case of component tests, are Wiremock server(s) span up by the tests themselves. The problems we have encountered that I feel are related to what was reported here:
So my question is - is there a reason why Feign clients are created/bound so early and would it be possible to change the order so they are created after all (or at least some) of the ports have been opened and their numbers are available? Thanks |
FYI, spring-cloud/spring-cloud-openfeign#455 seems to have fixed problem 2. |
Yes, that fixes the issue. Will backport it to Hoxton as well. |
A while ago I created a bug in Spring Cloud Contract (spring-cloud/spring-cloud-contract#1303)
After some more debugging it looks like the FeignRegistrar registers the feign client before the StubRunner is created, therefore the random port of the stub runner is not set for the feign client (the property that the stubrunner sets is "stubrunner.runningstubs.test-webapp.port", but it sets it too late).
In my example I would expect the test class annotations to be evaluated before the production annotations are.
See the Spring Cloud Contract issue for a sample demonstrating the unexpected behaviour.
The text was updated successfully, but these errors were encountered: