@SpringQueryMap does not work with records under certain conditions

Đang mở
#1,202 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java, mongodb, spring, spring-boot
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu với ứng dụng dummy được cung cấp và tái hiện request bằng một record khi spring-boot-starter-data-mongodb có mặt, sau đó so sánh với các trường hợp dựa trên class và không có dependency. Theo dõi cách xử lý @SpringQueryMap được Feign client sử dụng và thêm một regression test cho query string bị thiếu. Hoàn tất khi request của record gửi /test?foo=foo với MongoDB starter được bật.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

waiting-for-triage

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.

Ngôn ngữ chính
Java
Star
1.3k
Fork
834
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của spring-cloud/spring-cloud-openfeign

Tất cả issue của spring-cloud/spring-cloud-openfeign

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.