Support `ClientHttpMessageConvertersCustomizer` in `FeignHttpMessageConverters` for Spring Boot 4.0 Alignment
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- java, spring, spring-boot
Hướng nghiên cứu
Bắt đầu trong FeignHttpMessageConverters.java, đặc biệt là constructor và initConvertersIfRequired(), rồi kiểm tra ClientHttpMessageConvertersCustomizer khác với Feign HttpMessageConverterCustomizer hiện có như thế nào. Theo dõi luồng và thứ tự của ClientBuilder trước khi quyết định nên đặt các client customizers ở đâu. Được xem là hoàn tất khi các client customizers của Spring Boot 4 tác động đến các converter của Feign mà không làm hỏng hành vi hiện có của converter và Feign-customizer.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
With the architectural changes in Spring Boot 4.0 (as detailed in spring-projects/spring-boot#48310), the configuration of HTTP Message Converters has shifted from collecting all HttpMessageConverter beans from the context to using dedicated customizers (ClientHttpMessageConvertersCustomizer for clients and ServerHttpMessageConvertersCustomizer for servers).
Currently, FeignHttpMessageConverters in Spring Cloud OpenFeign constructs the converter list by collecting raw HttpMessageConverter<?> beans from the ObjectProvider and applying its own Feign-specific org.springframework.cloud.openfeign.support.HttpMessageConverterCustomizer.
This creates an inconsistency in the ecosystem. If I configure a converter using the standard Spring Boot 4.0 ClientHttpMessageConvertersCustomizer (intended for RestClient and RestTemplate), OpenFeign ignores it. I am forced to either:
- Define the converter as a raw
@Bean(which Spring Boot 4.0 discourages for auto-configuration context pollution). - Duplicate the configuration using the Feign-specific
HttpMessageConverterCustomizer.
Describe the solution you'd like
FeignHttpMessageConverters should detect and apply ClientHttpMessageConvertersCustomizer beans from the application context. This would allow a single point of configuration for all HTTP clients (Feign, RestClient, and RestTemplate) in a Spring Boot 4.0 application.
In FeignHttpMessageConverters.java, specifically within the initConvertersIfRequired() method, the logic builds an HttpMessageConverters instance using HttpMessageConverters.ClientBuilder. Since ClientHttpMessageConvertersCustomizer is designed to customize HttpMessageConverters, it seems natural to apply these customizers there.
Proposed logic change conceptually:
public class FeignHttpMessageConverters {
// Inject ClientHttpMessageConvertersCustomizer provider
private final ObjectProvider<ClientHttpMessageConvertersCustomizer> clientCustomizers;
// ... constructor ...
private void initConvertersIfRequired() {
if (this.converters == null) {
// ... existing builder logic ...
HttpMessageConverters hmc = builder.build();
// PROPOSED CHANGE: Apply Spring Boot Client Customizers
if (this.clientCustomizers != null) {
this.clientCustomizers.orderedStream().forEach(customizer -> customizer.customize(hmc));
}
// Continue with existing logic
hmc.forEach(converter -> converters.add(converter));
customizers.forEach(customizer -> customizer.accept(this.converters));
}
}
}
Describe alternatives you've considered
- Current Workaround: Defining a separate
@Beanfororg.springframework.cloud.openfeign.support.HttpMessageConverterCustomizerthat duplicates the logic present in myClientHttpMessageConvertersCustomizer. - Global Bean: Defining the converter as a global
@Beanmarked with@Primary. However, as mentioned in the linked Spring Boot issue, relying on collecting beans from the context is being revisited and might not be the preferred way forward for separate client/server configurations.
Additional context
References:
- Spring Boot Issue: Revisit HttpMessageConverters auto-configuration #48310
- Current implementation of
FeignHttpMessageConvertersrelies on:
It misses thepublic FeignHttpMessageConverters(ObjectProvider<HttpMessageConverter<?>> messageConverters, ObjectProvider<HttpMessageConverterCustomizer> customizers) { this.messageConverters = messageConverters; this.customizers = customizers; }ClientHttpMessageConvertersCustomizerwhich is now the standard for client-side configuration in Boot 4.
- Ngôn ngữ chính
- Java
- Star
- 1.3k
- Fork
- 834
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của spring-cloud/spring-cloud-openfeign
-
waiting-for-triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
spring-cloud/spring-cloud-openfeign#1452 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
question
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
spring-cloud/spring-cloud-openfeign#1392 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
FeignClientsConfiguration$MicrometerConfiguration.class cannot be opened because it does not existĐang mởfeedback-provided
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
spring-cloud/spring-cloud-openfeign#1379 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
waiting-for-triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
spring-cloud/spring-cloud-openfeign#1344 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
waiting-for-triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
spring-cloud/spring-cloud-openfeign#1343 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của spring-cloud/spring-cloud-openfeign
Issue tương tự
-
Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
MCP add-on: JSON responses with non-ASCII characters are truncated (wrong Content-Length)Có thể đã có người làm @dhanushbs10 đã nhận hôm nay. Đang mởadd-on bug in:mcp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
vaadin-map
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
vaadin/flow-components#10586 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
wpilibsuite/SystemcoreTesting#446 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
frontend quality-assurance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Paul-Austin-Oswego-CSC480-HCI521/gift-app#212 ·
Maintainer thường phản hồi trong vòng 1 ngày