针对#issues6086导出整合包时内存溢出修复#6173
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors both McbbsModpackExportTask and ModrinthModpackExportTask to stream JSON output directly using JsonWriter instead of constructing in-memory manifest objects. The review feedback highlights critical issues, including potential resource leaks from unclosed Files.walk streams and a potential NullPointerException when handling nullable Java versions. Additionally, the reviewer suggests refactoring repetitive loader version checks into loops to improve code readability and maintainability.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors both McbbsModpackExportTask and ModrinthModpackExportTask to write modpack manifests directly to temporary files using JsonWriter instead of serializing in-memory manifest objects. Feedback on these changes highlights several critical serialization bugs in the MCBBS export task, such as incorrect JSON keys (e.g., origins instead of origin, pluralized launch arguments, and supportedJavaVersions instead of supportJava), an incorrect type discriminator value, and missing default settings. Additionally, the reviewer notes that throwing a RuntimeException on remote file processing failures in the Modrinth export task could prematurely abort the export, and suggests refactoring ifPresent lambdas to standard loops or conditionals to avoid boilerplate try-catch blocks and RuntimeException wrapping.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the MCBBS and Modrinth modpack export tasks to stream JSON generation using JsonWriter to a temporary file, reducing memory overhead compared to the previous in-memory GSON serialization. However, several issues were identified in the review: using Files.walk instead of Files.walkFileTree introduces a severe performance regression by traversing blacklisted directories; writing explicit null values for optional fields like fileApi and summary may cause compatibility issues with strict parsers; and writing an empty origin array in the MCBBS manifest discards user-configured origin data.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors both McbbsModpackExportTask and ModrinthModpackExportTask to stream manifest and index JSON generation directly to a temporary file using JsonWriter instead of constructing large in-memory manifest objects. It also utilizes Files.walkFileTree for directory traversal. A critical issue was identified in ModrinthModpackExportTask where tryGetRemoteFile can throw an IOException that is no longer caught within the file visitor, which could cause the entire export task to fail on a single file error instead of logging a warning and continuing.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the MCBBS and Modrinth modpack export tasks to stream JSON metadata directly to temporary files using JsonWriter instead of building full in-memory manifest objects, which optimizes memory usage. It also replaces stream-based file walking with Files.walkFileTree. Feedback on these changes includes addressing a potential NullPointerException in McbbsModpackExportTask when iterating over tokenized launch and Java arguments, and optimizing the whitelist lookup in ModrinthModpackExportTask by converting the whitelist List to a HashSet to avoid O(N) performance overhead during directory traversal.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the MCBBS and Modrinth modpack export tasks to stream JSON manifests directly to temporary files using JsonWriter instead of building large in-memory objects. It also updates directory traversal to use Files.walkFileTree. The review feedback highlights critical issues in both export tasks where directory traversal (preVisitDirectory and zip.putDirectory) prematurely skips subtrees when a whitelist is present, because directory paths themselves are not in the whitelist. The reviewer recommends allowing traversal of non-blacklisted directories and applying the whitelist filter only to files.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors McbbsModpackExportTask and ModrinthModpackExportTask to stream their respective manifest files (mcbbs.packmeta and modrinth.index.json) directly to temporary files using JsonWriter instead of holding the entire manifest structures in memory. This is achieved by utilizing Files.walkFileTree to write files dynamically. A critical issue was identified in ModrinthModpackExportTask where enabling a disabled mod renames the file on disk but does not update the file reference, which can lead to a NoSuchFileException during subsequent operations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
|
你好!感谢你提交的关于修复大型整合包导出时 不过,我注意到你在评论区多次重复输入了 目前我已经根据你提供的补丁进行了分析,你的修复方案在逻辑上是正确的,使用了 如果后续有其他问题或需要进一步的反馈,请随时告知。 |
|
核心维护者们好,PR 中 CI 检查已全部通过。为了将 #6086 这个影响用户的 Bug 修复,这边的所有修改均已完成。请问是否还有其他地方需要调整?谢谢! |
问题:导出大型整合包时,HMCL 因
OutOfMemoryError卡死(见 #6086)。原因:
McbbsModpackExportTask和ModrinthModpackExportTask一次性将所有文件信息加载到内存生成 JSON,导致内存峰值过高修复:改用
JsonWriter流式写入临时文件,避免内存积累,并消除ModrinthModpackExportTask中重复的 API 调用和 I/O测试:已完成编译测试,本地通过且功能正常
关联:Fixes #6086