SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion paths
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start in SmartCompositeMessageConverter and compare the two-argument toMessage/fromMessage variants, which already do the instanceof and content-type checks, against the three-argument ones. Each bullet in the issue maps to one guard to copy over: null headers/content type, instanceof before casting, per-converter try/catch, null-safe element handling, and && instead of &. Add a test per case in the converter's existing test class, then run the module's test suite. Note that an open pull request (#1541) already targets this, so check with maintainers before starting.
索引モデルが issue の本文から書いたものです。
説明
SmartCompositeMessageConverter has several paths that fail with an unexpected exception instead of converting or returning null:
toMessage(payload, headers, hint)callsheaders.get(CONTENT_TYPE).toString(), which throwsNullPointerExceptionwhen the headers or the content type are missing (the two-argument variant checks the content type)- the same method casts each converter unconditionally to
AbstractMessageConverterandSmartMessageConverter, so a converter that is neither (for example one provided by the user) causesClassCastException, while the two-argument variant usesinstanceof - the three-argument
fromMessage(..)has notry/catchand no per-converter failure handling, unlike the two-argument variant, so one converter that throws (for example on a malformed content type header) aborts the whole chain - when converting an
Iterable,item.getClass()is called without a null check, so anullelement causesNullPointerException - one condition uses the non short-circuiting
&instead of&&
In addition, the MessageConversionException message contains the complete message (payload and headers), which may end up in logs or in responses if a caller exposes the exception message, and the converter list is copied for every message.
Proposed change: make the three-argument variants behave like the two-argument ones (null checks, instanceof checks, per-converter error handling), use &&, and add tests for each case above.
- 主要言語
- Java
- スター
- 1.1k
- フォーク
- 655
- 平均マージ
- 4時間 54分
- マージ済み PR(30日)
- 10
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-cloud/spring-cloud-function のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
spring-cloud/spring-cloud-function#1542 ·
メンテナーはふだん 1 日以内に返信
-
GcfJarLayout omits GcfJarLauncher$NestedUrlStreamHandlerFactory, causing NoClassDefFoundError under the GCF invoker対応中かも @zemiles が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 32/100
spring-cloud/spring-cloud-function#1544 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
spring-cloud/spring-cloud-function#1538 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Kotlin function wrapper treats empty input as no input対応中かも @seonwooj0810 が今日担当しました。 オープン5.0.x backport bug
難易度 3/5 半日 初心者へのやさしさ 30/100
spring-cloud/spring-cloud-function#1537 ·
メンテナーはふだん 1 日以内に返信
-
5.0.x backport bug
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
spring-cloud/spring-cloud-function#1536 ·
メンテナーはふだん 1 日以内に返信
spring-cloud/spring-cloud-function の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
aphtech/brailleblaster#209 ·
メンテナーはふだん 1 日以内に返信
-
payers.csv writes QOLS_AVG as NaN for every payer that had no members対応中かも @DG47 が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
synthetichealth/synthea#1797 ·
メンテナーはふだん 19 日以内に返信
-
build enhancement security
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
midhunhk/lib-aeapps#54 ·