Confusing behaviour: empty URL not allowed with default Client, but possible with ApacheHttpClient

Đang mở
#637 1 bình luận 0 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
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu tại FeignClientFactoryBean.loadBalance và so sánh đường dẫn Client mặc định với bean ApacheHttpClient được đăng ký bởi FeignAutoConfiguration.HttpClientFeignConfiguration. Xác định hành vi dự kiến đối với một URL @FeignClient rỗng và ghi lại hoặc kiểm thử kết quả để cả hai cấu hình đều có kết quả rõ ràng, nhất quán.

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

Mô tả

enhancement waiting for votes

My issue is related to https://github.com/spring-cloud/spring-cloud-openfeign/issues/517.

I found after some debugging that contrary to the situation described in that ticket, if ApacheHttpClient is on the classpath (in my case through a dependency on io.github.openfeign:feign-httpclient), it is very well possible to specify an empty String for the url in a @FeignClient (in my case, I did it like this: @FeignClient(name = "myfeignclient", url = "${my.url:}"), i.e. with an empty String as default value and the property being absent).

This allows the context to come up at least and will only result in an UnknownHostException when a request is actually attempted to be sent through that FeignClient.

For us, this is quite convenient though in a development environment where the destination is not known or when working on someone else's project so not all the required configuration needs to be known.

The crucial difference seems to be in the method loadBalance in FeignClientFactoryBean. Without the ApacheHttpClient being available as a bean, getOptional returns null, leading to the IllegalStateException.

A bean of type ApacheHttpClient seemingly becomes registered through FeignAutoConfiguration.HttpClientFeignConfiguration.

I'm thinking that if the Client.Default implementation was exposed as a bean, both situations would behave the same.

Would this be a reasonable change? I read @OlgaMaciaszek's point on the other ticket that it is intended to fail(?) by design, but why should it work then with ApacheHttpClient? (please don't take away that possibility though, like I said above, we like it 😉)

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.