`ToCloudEventTransformer`: binary mode sets `contentType` to `application/cloudevents`

オープン 初心者向け
#11,635 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

2026年10月28日 から。

  • #11636 @Adrastopoulos による — オープン

評価

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

調査の方向性

347行目付近の ToCloudEventTransformer.java と、167行目および225行目付近の ToCloudEventTransformerTests にあるバイナリモードのアサーションを読みます。トランスフォーマーがペイロードを保持して ce-* ヘッダーを書き込むときに、contentType をどのように設定するか確認します。入力の application/json コンテントタイプが保持されるようにバイナリモードの期待値を更新し、テストで期待される CloudEvent データのコンテントタイプとペイロードがカバーされていることを確認します。

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

説明

in: cloudevents type: bug

Spring Integration 7.1.2, cloudevents-spring 5.1.0.

In binary mode, ToCloudEventTransformer keeps the event data as the payload and writes the attributes as ce-* headers, but it also replaces contentType with application/cloudevents (MessageBuilderMessageWriter#create(…), line 347). The CloudEvents bindings use that media type to mark structured mode; in binary mode the content type is the datacontenttype (HTTP binding §3 and §3.1.1, AMQP binding §3 and §3.1.1). So the CloudEvents SDK can't read the output:

Message<byte[]> input = MessageBuilder.withPayload("{\"order\":42}".getBytes(StandardCharsets.UTF_8))
    .setHeader(MessageHeaders.CONTENT_TYPE, "application/json")
    .build();

Message<?> output = (Message<?>) toCloudEventTransformer.transform(input);
new CloudEventMessageConverter().fromMessage(output, CloudEvent.class);
  • Expected: a CloudEvent with datacontenttype application/json and the payload as its data.
  • Actual: CloudEventRWException: Could not parse. Unknown encoding. Invalid content type or spec version.

With contentType set back to application/json, the same message reads correctly.

Suggested fix: in binary mode, keep the input's contentType, since the payload doesn't change. ToCloudEventTransformerTests asserts the current value at lines 167 and 225.

主要言語
Java
スター
1.6k
フォーク
1.2k
平均マージ
20時間 16分
マージ済み PR(30日)
79

環境構築

はじめの一歩

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

spring-projects/spring-integration のほかの issue

spring-projects/spring-integration の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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