spring-cloud / spring-cloud/spring-cloud-openfeign
@SpringQueryMap does not work with records under certain conditions
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.3k
- Forks
- 838
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 13
Description
We ran into an issue where @SpringQueryMap was not working in one of our apps. I created a dummy app to try and diagnose the issue, but it wasn't until I stumbled across this bug that I identified the problem. Unlike the other bug, it was spring-boot-starter-data-mongodb in our case. Below is some sample code. Without spring-boot-starter-data-mongodb, it works fine. Add spring-boot-starter-data-mongodb and the querystring no longer gets sent.
@FeignClient(name = "scratch-service", url = "http://localhost:8091")
public interface ScratchClient
{
@Builder
record Test(String foo)
{
}
@GetMapping("/test")
void test(@SpringQueryMap final Test test);
}
@RequiredArgsConstructor
@Slf4j
@RestController
public class ScratchController
{
private final ScratchClient scratchClient;
@GetMapping("/test")
public void test(final ScratchClient.Test test)
{
log.info("test: {}", test);
}
@GetMapping("/feign")
public void feign()
{
scratchClient.test(ScratchClient.Test.builder().foo("foo").build());
}
}
with spring-starter-data-mongodb...
http-outgoing-0 >> GET /test HTTP/1.1
without...
http-outgoing-0 >> GET /test?foo=foo HTTP/1.1
This was tested with Spring Boot 3.4.5 and Spring Cloud 2024.0.1
Switching it from a record to a class does not have this compatibility issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied dummy application and reproduce the request with a record while spring-boot-starter-data-mongodb is present, then compare it with the class-based and dependency-free cases. Trace the @SpringQueryMap handling used by the Feign client and add a regression test for the missing query string. Done means the record request sends /test?foo=foo with the MongoDB starter enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mongodb, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100