@SpringQueryMap does not work with records under certain conditions
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.
Any update on this? seeing the same thing.
It doesn't work with Java Record, if you create the getters in the record, it works.