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

Absent nested optional shennanigans

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
java
領域
backend

調査の方向性

まず、Jdk8Moduleを使用したrecord/ObjectMapperの例を再現し、Optionalのデシリアライズのエントリーポイントを追跡します。既存のテストで、存在しないネストされたOptionalsがカバーされているか確認します。完了の条件は、意図する結果についてmaintainerの判断が示され、その動作と理由が回帰テストまたはドキュメントに記録されていることです。

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

説明

Uh... so this is partially for science, I guess. It's obscure enough to not matter, but I'd like to understand the reasoning. I stumbled upon this because I am working on a smaller databind library myself and of course I'm always comparing to Jackson for sensible defaults. Observe the following:

record R(Optional<Optional<String>> s) { }

R r = new ObjectMapper()
	.registerModule(new Jdk8Module())
	.readValue("{}", new TypeReference<>() {});

assertFalse(r.s.isPresent());

Here, an Optional<Optional<String>> property is absent from the JSON to deserialize. Naively, I expected the property to be set to an empty optional, but actually it's Optional.of(Optional.empty()), so the snippet above crashes.

I didn't find any tests which explicitly cover this here, so I guess it wasn't really considered a worthwhile edge case. But I think following through with these weird cases helps in figuring out consistent behaviour in general. Do you think that the current behaviour (Optional.of(Optional.empty())) is correct or do you think Optional.empty() would be correct?

主要言語
Java
スター
425
フォーク
125
平均マージ
19分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

FasterXML/jackson-modules-java8 のほかの issue

FasterXML/jackson-modules-java8 の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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