Repository navigation
fix(bean)!: 完善 Map 导出及异常双向转换 - #385
Merged
Merged
Conversation
源属性仅求值一次,Bean 转 Map 时排除 transient 字段及 JavaBeans Transient 属性,保留只读源属性与按名称取值能力。 异常直接转 Map 时输出类型、消息、完整堆栈文本和国际化信息, 通过延迟字段 SPI 支持上层替换异常映射及堆栈精简。 BREAKING CHANGE: Bean 转 Map 不再导出 transient 属性;Throwable 转 Map 改为固定描述字段,不再枚举 cause、suppressed 等任意属性。
已兼容的 Throwable 保留原引用,异常描述通过双向 SPI 受控还原。 平台国际化异常恢复为对应 NoStackTrace 实现,未知类型使用安全包装, 保留远端类型、诊断、消息回退、参数及校验详情,不按类型名加载类。 统一普通 Bean、record、类目标和已有异常目标的转换路径,校验目标 可赋值性及描述字段。将本 PR 未发布的 SPI 收敛为 ExceptionConverter。
保留无译文的远端消息原文,避免重复格式化引起单引号和括号损坏。 让校验异常详情支持 Java 序列化,统一空忽略集行为。 补充循环引用、畸形输入、并发 SPI 和国际化边界回归,隔离启动配置测试。
验证常见检查异常、运行时异常、Error、包装异常和自定义平台子类, 确保描述中转保留元数据、兼容实例直通及未知具体目标明确失败。
异常显示名称为空时回退二进制类名,保留普通命名类及诊断格式。 覆盖匿名类、局部类、空名称扩展,以及匿名平台异常直接和嵌套转 Map。
zhou-hao
added a commit
that referenced
this pull request
Nov 27, 2026
回移 transient 排除、getter 单次读取和双向异常转换 SPI。 保留国际化、业务字段和远端诊断,核心异常恢复为对应无栈实现。 修复 TraceSourceException 在匿名或局部类诊断输出时的空指针。 Refs: #385 BREAKING CHANGE: Bean 转 Map 不再导出 transient 属性;Throwable 转 Map 使用固定描述,不再枚举 cause、suppressed 等任意属性。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bean 转 Map 会读取本应仅保留在本地的 transient 属性,非空引用属性的 getter 还会重复执行。现在在读取前排除 transient 字段(含继承字段)及 JavaBeans Transient 属性,对参与复制的属性只求值一次,保留只读 Bean、record、fluent、Extendable 和 getProperty 的用途。
异常转换使用双向 ExceptionConverter SPI:
验证:
兼容影响:Bean 转 Map 不再导出 transient 属性,显式 include 也不能绕过;Throwable 转 Map 不再枚举原始 cause、suppressed、stackTrace 对象。detail 为诊断文本,不解析成异常对象图。普通 Bean 内非 transient 的异常、args 和校验详情中的业务值保持浅引用,任意业务值能否序列化取决于值本身。未支持的具体异常目标需由 SPI 提供可赋值实现,否则明确失败。
5.0.3 维护分支的回移见 PR #386。