SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion paths

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

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

@seonwooj0810 がすでに取り組んでいます。

2026年11月23日 から。

  • #1541 @seonwooj0810 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend

調査の方向性

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 の本文から書いたものです。

説明

5.0.x backport bug

SmartCompositeMessageConverter has several paths that fail with an unexpected exception instead of converting or returning null:

  • toMessage(payload, headers, hint) calls headers.get(CONTENT_TYPE).toString(), which throws NullPointerException when the headers or the content type are missing (the two-argument variant checks the content type)
  • the same method casts each converter unconditionally to AbstractMessageConverter and SmartMessageConverter, so a converter that is neither (for example one provided by the user) causes ClassCastException, while the two-argument variant uses instanceof
  • the three-argument fromMessage(..) has no try/catch and 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 a null element causes NullPointerException
  • 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

環境構築

はじめの一歩

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

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

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

似ている issue

Java の issue をもっと見る

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

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