Skip to content

fix(pay): 企业付款到银行卡使用后立即删除临时公钥文件,避免运行期间临时文件堆积 - #4143

Merged
binarywang merged 1 commit into
developfrom
fix/pay-bank-tempfile-delete
Oct 24, 2026
Merged

binarywang merged 1 commit into
developfrom
fix/pay-bank-tempfile-delete

Conversation

@binarywang

Copy link
Copy Markdown
Owner

Summary

企业付款到银行卡的 payBank() 原先仅在 JVM 退出时删除临时公钥文件,长期运行时可能持续堆积。改为在 finally 中删除,覆盖正常返回及异常路径。

- 加密后注册 deleteOnExit()
+ try 执行加密及支付流程
+ finally 删除临时公钥文件

迁移自 Gitee PR #181,原作者为 xy。完整保留原提交 cb2eeaf94b20300678dcd7a0771ad647f2968d29,未修改代码、作者、提交者或提交时间。

Evidence

  • Before: 临时公钥文件只在 JVM 退出时清理。
  • After: buildPublicKeyFile() 成功返回后,正常返回及加密、签名、请求、响应校验异常均执行清理;公钥读取流由 try-with-resources 关闭。
  • 已完成静态审查及 git diff --check;未运行自动化测试或真实支付调用。
  • 原 PR 提及的 Gitee Issue I9DBP9 描述的是公众号二维码临时文件,本次支付模块变更不视为解决该 Issue。

Merge Danger

Door: two-way

可通过回退该提交撤销。

Blast Radius: 支付

仅影响企业付款到银行卡的临时公钥文件清理。File.delete() 返回值仍未检查,清理失败时可能遗留文件;本次迁移保留原实现,供后续审查处理。

Copilot AI balanced review requested due to automatic review settings October 24, 2026 09:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T09:54:20.617001Z cb2eeaf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

变更范围明确,公钥读取流在删除前已关闭,正常及异常路径均执行清理,未发现阻断性问题。

No open issues 🎉

What changed in this PR

本次变更调整微信支付模块企业付款到银行卡的临时公钥文件清理时机,减少长期运行时的临时文件堆积。

变更:

  • 将 JVM 退出时清理改为在 payBank() 的 finally 中尝试立即删除。
  • 覆盖临时文件创建成功后的正常返回及异常路径,保持加密、签名和支付流程不变。

审查基于静态证据,未运行自动化测试或真实支付调用。

File Description
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​impl/​EntPayServiceImpl.java 使用 try/finally 清理临时公钥文件。

Review effort: Balanced

@augmentcode

augmentcode Bot commented Oct 24, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

将 payBank() 临时公钥文件的清理从 deleteOnExit() 改为在 finally 中立即尝试删除,避免长期运行时文件堆积。
文件创建成功后,正常返回及加密、签名、请求、响应校验的异常路径均会执行清理,原有支付业务逻辑不变。

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@binarywang
binarywang merged commit 1b22c25 into develop Oct 24, 2026
3 checks passed
@binarywang
binarywang deleted the fix/pay-bank-tempfile-delete branch October 24, 2026 09:57
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.

3 participants