Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`WebClient` with default codecs drops `ProblemDetail` extension members

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

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

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

  • #37507 @zsewasdsdsd による — マージされずにクローズ

評価

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

調査の方向性

ギャップは org.springframework.http.codec.json の JacksonJsonDecoder にあります。JacksonJsonEncoder と異なり、デフォルトコンストラクタと JsonMapper.Builder を受け取るコンストラクタのどちらでも ProblemDetailJacksonMixin を登録していません。まず両クラスを並べて比較し、次に ProblemDetail のデコードに関する既存のコーデックテストを確認して、デコーダー用の対応するテストをどこに置くべきかを見極めてください。デフォルトのコーデックで構成された WebClient が getProperties() の拡張メンバーを保持することが完了条件で、noojung/webclient-problemdetail-mixin-repro のサンプルで再現します。PR (#37507) はすでに開かれ、マージされずにクローズされていることに注意し、重複させる前にスレッドを確認してください。

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

説明

status: waiting-for-triage

Overview

While checking that RestClient and WebClient decode ProblemDetail responses correctly, I noticed that a WebClient created with the default codecs (WebClient.create() or WebClient.builder()) drops RFC 9457 extension members: getProperties() returns null, while the standard members are decoded correctly.

This worked with Spring Framework 6.2 (Spring Boot 3.5), so it looks like a regression introduced with the Jackson 3 codecs.

Versions tested

  • Spring Framework 7.0.9 (Spring Boot 4.1.1, Jackson 3): extension members are lost
  • Spring Framework 6.2.11 (Spring Boot 3.5.6, Jackson 2): works as expected

Reproducer

With the sample server running on port 8080, GET /orders/42 returns HTTP 404 with Content-Type: application/problem+json and the following body:

{
  "type": "https://example.com/problems/order-not-found",
  "title": "Order Not Found",
  "status": 404,
  "detail": "Order 42 does not exist",
  "instance": "/orders/42",
  "errorCode": "ORDER_NOT_FOUND",
  "orderId": 42
}

The extension members are lost when decoding the response:

WebClient webClient = WebClient.create("http://localhost:8080");
// Also reproduces with:
// WebClient.builder().baseUrl("http://localhost:8080").build();

WebClientResponseException.NotFound exception = assertThrows(
        WebClientResponseException.NotFound.class,
        () -> webClient.get()
                .uri("/orders/42")
                .retrieve()
                .bodyToMono(Order.class)
                .block());

ProblemDetail problemDetail = exception.getResponseBodyAs(ProblemDetail.class);

assertThat(problemDetail).isNotNull();
assertThat(problemDetail.getProperties())
        .containsEntry("errorCode", "ORDER_NOT_FOUND")
        .containsEntry("orderId", 42);
// 6.2.11: passes
// 7.0.9:  fails because getProperties() returns null

A complete sample (Spring MVC server + WebClient/RestClient tests) is available here: https://github.com/noojung/webclient-problemdetail-mixin-repro

Running ./gradlew test starts the server automatically and fails webClientCreateShouldPreserveProblemDetailProperties and webClientBuilderShouldPreserveProblemDetailProperties.

For comparison, RestClient.create() and the WebClient.Builder auto-configured by Spring Boot both keep the extension members, since JacksonJsonHttpMessageConverter registers the mixin and Boot configures the codecs with a JsonMapper that has it (spring-projects/spring-boot#47298).

Analysis

JacksonJsonEncoder and JacksonJsonHttpMessageConverter register ProblemDetailJacksonMixin in their default and JsonMapper.Builder-based constructors, but JacksonJsonDecoder does not. Since FAIL_ON_UNKNOWN_PROPERTIES is disabled by default in Jackson 3, the extension members are ignored without any error.

With Jackson 2, the default Jackson2JsonDecoder created its mapper through Jackson2ObjectMapperBuilder, which registers the mixin.

Workaround

WebClient webClient = WebClient.builder()
        .codecs(configurer -> configurer.defaultCodecs().jacksonJsonDecoder(new JacksonJsonDecoder(
                JsonMapper.builder().addMixIn(ProblemDetail.class, ProblemDetailJacksonMixin.class))))
        .build();

Related issues

  • #35597
  • spring-projects/spring-boot#47298

Would registering ProblemDetailJacksonMixin in the default and JsonMapper.Builder-based constructors of JacksonJsonDecoder, the same way as in JacksonJsonEncoder, be the right fix? If so, I would be happy to submit a pull request.

主要言語
Java
スター
60.3k
フォーク
38.7k
平均マージ
1日 8時間
マージ済み PR(30日)
35

環境構築

はじめの一歩

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

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

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

似ている issue

Java の issue をもっと見る

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

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