Default JSON mapper collection limit is hard-coded and replaces all collection deserialization

未关闭
#1,536 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
22/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
java, spring
领域
backend

调研方向

Read the JacksonMapper bean method in ContextFunctionCatalogAutoConfiguration first, then CollectionLimitModule and LimitedCollectionDeserializer to see how the deserializer modifier replaces every Collection deserializer. There is no test coverage today, so start by writing a failing test that deserializes a LinkedList and a TreeSet through the default mapper, plus one that exceeds the limit. Done means the limit is configurable, the requested collection type and any pre-existing deserializer are preserved by delegation, violations surface as Jackson exceptions, and the Joda UTCProvider call no longer depends on the fallback path.

由索引模型根据 Issue 内容生成。

描述

5.0.x backport bug

The default JacksonMapper created in ContextFunctionCatalogAutoConfiguration registers CollectionLimitModule, whose deserializer modifier replaces the deserializer of every Collection type with LimitedCollectionDeserializer. This has several problems:

  • the limit is a constant (MAX_ITEMS = 1000) and can not be configured, so a legitimate batch with more than 1000 elements fails
  • the failure is a plain IllegalStateException("Collection size exceeds limit of 1000") rather than a Jackson exception, so it is not handled like other deserialization errors
  • the deserializer always creates an ArrayList, or a HashSet for Set types, regardless of the requested type, so LinkedList, TreeSet, LinkedHashSet (order is lost), ArrayDeque and similar targets do not get the collection type that was asked for
  • any custom or more specific collection deserializer, including ones registered on the user's ObjectMapper that the mapper is rebuilt from, is replaced, because the modifier ignores the deserializer it is given
  • the deserializer reads elements with getBoundType(0) of the declared type and does not handle null tokens, polymorphic type information or a start token that is not an array

There are no tests for LimitedCollectionDeserializer or CollectionLimitModule.

Separately, when no ObjectMapper bean can be rebuilt, the fallback in the same method calls DateTimeZone.setProvider(new UTCProvider()), which changes the Joda time zone provider for the whole JVM depending on whether a bean was present.

Proposed change: make the limit configurable (or use Jackson's own stream read constraints), keep the requested collection type and any existing deserializer by delegating to it, throw a Jackson exception on violations, and add tests for the cases above. The Joda provider change should not depend on the fallback path.

主要语言
Java
星标
1.1k
派生
655
平均合并
4 小时 54 分钟
30 天内合并 PR
10

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

spring-cloud/spring-cloud-function 的其他 Issue

查看 spring-cloud/spring-cloud-function 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。