优化 ArchiveFileTree 构建性能 - #6838
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebca625d38
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ZipArchiveEntry entry = reader.getEntry(entryPath); | ||
| if (entry != null) | ||
| return entry; |
There was a problem hiding this comment.
Apply tree filtering before returning ZIP entries
When a ZIP contains an entry that addEntry rejects—such as a/file.txt after a file named a, or a path containing a .. parent component—this fast path still returns that exact entry directly from the reader. As a result, ZipFileTree.getEntry and helpers such as readTextEntry can access entries that the new conflict/traversal policy says were skipped, unlike TarFileTree and tree traversal. Only return the direct result when it is known to be valid under the same filtering rules, or resolve the lookup through the filtered tree.
Useful? React with 👍 / 👎.
| if (root == null) { | ||
| root = new Dir<>(""); |
There was a problem hiding this comment.
Publish the lazy root only after construction
If two threads first call getRoot() on the same tree concurrently, the first call publishes root before adding any entries, so the second call can observe and return an empty or partially populated tree. Both ZIP and TAR implementations use this pattern, regressing concurrent read access from the previously eager, fully constructed root; build into a local variable and publish it with synchronization or another safe lazy-initialization mechanism.
Useful? React with 👍 / 👎.
根据 JFR 结果,ArchiveFileTree 创建时的性能开销是另一个热点。本 PR 优化了构建 ArchiveFileTree 的性能,减少了内存分配。