SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion paths
维护者通常 1 天内回复
评估
调研方向
Start in SmartCompositeMessageConverter and compare the two-argument toMessage/fromMessage variants, which already do the instanceof and content-type checks, against the three-argument ones. Each bullet in the issue maps to one guard to copy over: null headers/content type, instanceof before casting, per-converter try/catch, null-safe element handling, and && instead of &. Add a test per case in the converter's existing test class, then run the module's test suite. Note that an open pull request (#1541) already targets this, so check with maintainers before starting.
由索引模型根据 Issue 内容生成。
描述
SmartCompositeMessageConverter has several paths that fail with an unexpected exception instead of converting or returning null:
toMessage(payload, headers, hint)callsheaders.get(CONTENT_TYPE).toString(), which throwsNullPointerExceptionwhen the headers or the content type are missing (the two-argument variant checks the content type)- the same method casts each converter unconditionally to
AbstractMessageConverterandSmartMessageConverter, so a converter that is neither (for example one provided by the user) causesClassCastException, while the two-argument variant usesinstanceof - the three-argument
fromMessage(..)has notry/catchand no per-converter failure handling, unlike the two-argument variant, so one converter that throws (for example on a malformed content type header) aborts the whole chain - when converting an
Iterable,item.getClass()is called without a null check, so anullelement causesNullPointerException - one condition uses the non short-circuiting
&instead of&&
In addition, the MessageConversionException message contains the complete message (payload and headers), which may end up in logs or in responses if a caller exposes the exception message, and the converter list is copied for every message.
Proposed change: make the three-argument variants behave like the two-argument ones (null checks, instanceof checks, per-converter error handling), use &&, and add tests for each case above.
- 主要语言
- Java
- 星标
- 1.1k
- 派生
- 655
- 平均合并
- 4 小时 54 分钟
- 30 天内合并 PR
- 10
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
spring-cloud/spring-cloud-function 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
spring-cloud/spring-cloud-function#1542 ·
维护者通常 1 天内回复
-
GcfJarLayout omits GcfJarLauncher$NestedUrlStreamHandlerFactory, causing NoClassDefFoundError under the GCF invoker可能已有人在做 @zemiles 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 32/100
spring-cloud/spring-cloud-function#1544 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
spring-cloud/spring-cloud-function#1538 · 1 条评论 ·
维护者通常 1 天内回复
-
Kotlin function wrapper treats empty input as no input可能已有人在做 @seonwooj0810 今天认领。 未关闭5.0.x backport bug
难度 3/5 半天 新手友好度 30/100
spring-cloud/spring-cloud-function#1537 ·
维护者通常 1 天内回复
-
5.0.x backport bug
难度 4/5 3-5 天 新手友好度 22/100
spring-cloud/spring-cloud-function#1536 ·
维护者通常 1 天内回复
查看 spring-cloud/spring-cloud-function 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 1/5 1 小时以内 新手友好度 80/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
aphtech/brailleblaster#209 ·
维护者通常 1 天内回复
-
payers.csv writes QOLS_AVG as NaN for every payer that had no members可能已有人在做 @DG47 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 86/100
synthetichealth/synthea#1797 ·
维护者通常 19 天内回复
-
build enhancement security
难度 2/5 1-3 小时 新手友好度 78/100
midhunhk/lib-aeapps#54 ·