ClassCastException with spring-cloud-function 4.3.6 when a field of type Set is deserialized

未關閉 適合新手
#1,542 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
70/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java, spring-boot
領域
backend

研究方向

在 Jackson 整合套件中尋找 CollectionLimitModule 以及它建構的 LimitedCollectionDeserializer;這個 bug 出在建構子參數上,它在需要集合型別的地方傳入了集合的元素型別,導致每個受限集合都變成 ArrayList。先解壓縮附帶的重現專案並針對 4.3.6 執行其測試以看到 JsonMappingException,接著用本機建置重現同樣的路徑。完成的標準是:Set<String> 屬性會還原序列化為 Set,List 的行為和 1000 項限制保持不變,而且該模組現有的測試通過。

由索引模型根據 Issue 內容生成。

描述

spring-cloud-function 4.3.6 registers a CollectionLimitModule on the JsonMapper it creates, to reject collections with more than 1000 items. Its LimitedCollectionDeserializer is created with the element type of the collection instead of the collection type, so it always creates an ArrayList. Any message or function argument with a Set property (for example a Set<String> that receives []) failed with JsonMappingException: ... expected type: [collection type; class java.util.Set ...]; actual type: java.util.ArrayList, problem: argument type mismatch. List properties were not affected. spring-cloud-function 4.3.5 does not have the problem.

The attached project has unit tests that reproduces the issue. All tests pass if you replace the value of spring-cloud-function.version from 4.3.6 to 4.3.5 in pom.xml.

scf-set-deserialization-repro.zip

主要語言
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 摘要。