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

オープン
#637 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java
領域
api, backend

調査の方向性

FeignClientFactoryBean.loadBalance から開始し、デフォルトの Client パスと FeignAutoConfiguration.HttpClientFeignConfiguration によって登録された ApacheHttpClient Bean を比較します。空の @FeignClient URL に対する想定される動作を確認し、その結果を文書化またはテストして、両方の構成で明示的かつ一貫した結果になるようにします。

索引モデルが issue の本文から書いたものです。

説明

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 😉)

主要言語
Java
スター
1.3k
フォーク
834
平均マージ
3日 6時間
マージ済み PR(30日)
14

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

spring-cloud/spring-cloud-openfeign のほかの issue

spring-cloud/spring-cloud-openfeign の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。