HttpServiceProxyFactory proxy throws IllegalStateException when toString() is invoked on HTTP service interface proxy
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 68/100
調査の方向性
まず HttpServiceProxyFactory.HttpServiceMethodInterceptor を読み、特にその invoke メソッドと issue で挙げられている Object メソッドのケースを確認してください。HTTP サービスプロキシの動作に関する近くのテストを確認し、toString()、equals()、hashCode() のテストを追加してください。これらの呼び出しで例外が発生しなくなり、既存のプロキシテストが通れば issue は完了です。
索引モデルが issue の本文から書いたものです。
説明
When using an HTTP service interface created through HttpServiceProxyFactory, invoking Object.toString() on the generated proxy causes an IllegalStateException.
The issue becomes visible during Spring Cloud bootstrap logging because a PropertySource contains a ConsulClient proxy and PropertySource.toString() indirectly invokes toString() on that proxy.
Expected behavior:
• HTTP service proxies should safely handle toString(), equals() and hashCode()
• Logging a structure containing such proxies should not fail
Actual behavior:
• Object.toString() invocation reaches HttpServiceMethodInterceptor
• HttpServiceMethodInterceptor throws:
IllegalStateException:
Unexpected method invocation:
public java.lang.String java.lang.Object.toString()
Stack Trace
java.lang.IllegalStateException:
Unexpected method invocation:
public java.lang.String java.lang.Object.toString()
at org.springframework.web.service.invoker.HttpServiceProxyFactory$HttpServiceMethodInterceptor.invoke(HttpServiceProxyFactory.java:308)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:222)
at jdk.proxy2.$Proxy54.toString(Unknown Source)
Relevant Code
Current implementation:
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
HttpServiceMethod httpServiceMethod =
this.httpServiceMethods.get(method);
if (httpServiceMethod != null) {
return httpServiceMethod.invoke(arguments);
}
if (method.isDefault()) {
...
}
throw new IllegalStateException(
"Unexpected method invocation: " + method);
}
The interceptor does not handle:
Object.toString()
Object.equals()
Object.hashCode()
and therefore fails when any of those methods are invoked.
Minimal Reproducer
HTTP service interface:
public interface DemoClient {
@GetExchange("/demo")
String demo();
}
Proxy creation:
DemoClient client =
HttpServiceProxyFactory.builderFor(adapter)
.build()
.createClient(DemoClient.class);
Trigger:
System.out.println(client.toString());
Result:
IllegalStateException:
Unexpected method invocation:
public java.lang.String java.lang.Object.toString()
Expected Behavior
The generated proxy should support standard Object methods, for example:
client.toString();
client.hashCode();
client.equals(other);
without throwing exceptions.
Additional Context
The issue became visible after migrating from a traditional Consul client implementation to the new Spring HTTP Interface based ConsulClient.
The problem is not related to Consul itself, but to the generic handling of Object methods by HttpServiceProxyFactory generated proxies.
- 主要言語
- Java
- スター
- 751
- フォーク
- 771
- 平均マージ
- 3日 15時間
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-cloud/spring-cloud-commons のほかの issue
-
enhancement for team discussion
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
spring-cloud/spring-cloud-commons#1676 ·
メンテナーはふだん 1 日以内に返信
-
waiting-for-triage
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
spring-cloud/spring-cloud-commons#1675 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
waiting-for-triage
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
spring-cloud/spring-cloud-commons#1640 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
waiting-for-triage
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
spring-cloud/spring-cloud-commons#1629 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement help wanted
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
spring-cloud/spring-cloud-commons#1619 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
spring-cloud/spring-cloud-commons の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NucleusFramework/Nucleus#1020 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
ajeetraina/awesome-docker-sbx#839 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
portfolio-performance/portfolio#6459 ·
メンテナーはふだん 2 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
bufbuild/protovalidate-java#564 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
it-at-m/traegerportal#17 ·