Absent nested optional shennanigans
还没有人认领这个 Issue。
评估
调研方向
首先使用 Jdk8Module 复现 record/ObjectMapper 示例,并跟踪 Optional 反序列化的入口点。检查现有测试是否覆盖缺失的嵌套 Optionals;完成的标准是维护者对预期结果作出决定,并将行为及其理由记录在回归测试或文档中。
由索引模型根据 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 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
FasterXML/jackson-modules-java8 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 72/100
-
难度 4/5 3-5 天 新手友好度 25/100
FasterXML/jackson-modules-java8#382 · 3 条评论 ·
-
date-time-config
难度 4/5 3-5 天 新手友好度 35/100
FasterXML/jackson-modules-java8#374 · 31 条评论 · 1 个 reaction ·
-
test-needed
难度 5/5 一周以上 新手友好度 35/100
FasterXML/jackson-modules-java8#304 · 3 条评论 ·
-
pr-welcome test-needed
难度 4/5 3-5 天 新手友好度 35/100
FasterXML/jackson-modules-java8#299 · 4 条评论 · 1 个 reaction ·
查看 FasterXML/jackson-modules-java8 的全部 Issue
相似的 Issue
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
apache/flink-agents#1152 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
jenkinsci/blueocean-plugin#5417 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
objectionary/eo-graphs#75 ·