Skip to content

修复文件上传触发防重复摘要栈溢出 - #62

Open
Ycymac wants to merge 1 commit into
nageoffer:mainfrom
Ycymac:codex/fix-idempotent-multipart
Open

修复文件上传触发防重复摘要栈溢出#62
Ycymac wants to merge 1 commit into
nageoffer:mainfrom
Ycymac:codex/fix-idempotent-multipart

Conversation

@Ycymac

@Ycymac Ycymac commented Jul 23, 2026

Copy link
Copy Markdown

修改内容

  • MultipartFile 注册 Gson 层级序列化适配器
  • 生成防重复摘要时仅保留字段名、原始文件名、内容类型和文件大小
  • 避免递归序列化 Multipart 实现及读取文件字节
  • 增加 20MB 文件回归测试,覆盖不同文件内容不参与摘要、文件名仍参与摘要的行为

问题原因

IdempotentSubmitAspect 默认通过 gson.toJson(joinPoint.getArgs()) 生成请求参数摘要。请求参数包含 MultipartFile 时,Gson 会继续序列化其具体实现,可能递归进入底层请求结构或处理大块文件内容,最终导致栈溢出或不必要的内存开销。

影响

普通请求参数的摘要逻辑保持不变。文件上传请求不再读取文件字节;同一用户、请求路径以及文件元数据相同的并发提交仍会命中同一个防重复 Key。

验证

mvn -pl framework -am "-DskipTests=false" "-Dtest=IdempotentSubmitAspectTest" "-Dsurefire.failIfNoSpecifiedTests=false" test

测试结果:1 个测试通过,无失败或错误。

@Ycymac
Ycymac marked this pull request as ready for review July 23, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant