Describe the bug There seems to be a breaking change when upgrading from 2.2.3.RELEASE to the latest GA version (2.2.5.RELEASE). Actually, upgrading to 2.2.4.RELEASE is broken too.
The issue is in generated client's URLs. A very basic client like this:
@FeignClient(name = "client", url = "http://localhost:8585", path = "/path")
interface Client {
@RequestMapping("/") // note this slash here
fun call(@RequestParam(name = "param") param: String): String
}
is sending requests to http://localhost:8585/path?param=… when using 2.2.3.RELEASE, but in 2.2.4.RELEASE and later the URL is different: http://localhost:8585/path/?param=…. Note that extra slash after path in the second scenario.
Although, such trailing slashes seems to be ignored by most server applications, like the ones authored with Spring Boot, probably not all APIs or servers are so tolerant. The MWE below demonstrates the consequence of such intolerance in WireMock. Some companies are using WireMock for functional, integration and contract testing. Contract tests are just "dumb" stubs / mocks and they expect the exact URL, so upgrading from 2.2.3.RELEASE breaks them.
I guess, the issue was introduced by this commit: https://github.com/spring-cloud/spring-cloud-openfeign/commit/14929cbfee02580a8b0684bb665b7b335f957aa6.
Sample
Please, find the full source code of the minimal working example here: madhead/spring-cloud-openfeign-mwe. Try changing the version of spring-cloud-starter-openfeign in its build.gradle.kts. The test will pass with 2.2.3.RELEASE, but fail with 2.2.4.RELEASE. 2.2.5.RELEASE (latest GA version as of publishing this issue) is affected as well.
Comment From: OlgaMaciaszek
Hi @madhead That was just a revert of a commit that introduced a bug while adding a rarely used feature, but let me have a look at it now.
Comment From: OlgaMaciaszek
Have gone through the issue history and the actual situation is that removing the slash was causing this issue. Both urls with and without the trailing slash are permitted as per Uniform Resource Identifier (URI): Generic Syntax, so we should allow the users to decide on whether to add it (by adding @RequestMapping("/")) or not (by just annotating with @RequestMapping, without any arguments, instead).
I recognise that it's a bad situation that there's a breaking change, however, it only affects tests and it is a fix for a breaking change that introduced actual issues, for example, in libraries built on top of this one.
Comment From: madhead
Ok, I understand.