Visitar URL original
[COMPRESS-643] Reset ZIP entry counts after draining previous entries by hutiefang76 · Pull Request #838 · apache/commons-compress · GitHub
Skip to content

[COMPRESS-643] Reset ZIP entry counts after draining previous entries - #838

Open
hutiefang76 wants to merge 2 commits into
apache:masterfrom
hutiefang76:frank/fix-compress643-entry-count-20261110
Open

hutiefang76 wants to merge 2 commits into
apache:masterfrom
hutiefang76:frank/fix-compress643-entry-count-20261110

Conversation

@hutiefang76

Copy link
Copy Markdown

Advancing to the next ZIP entry closes the previous entry implicitly. For a DEFLATED entry with a data descriptor, that close can drain unread data through read(). The counter was reset before this drain, so the next entry inherited the previous entry's unread-byte count. A 100000-byte unread entry left the next entry starting at 100000 instead of zero.

Reset the uncompressed count after closing the previous entry, while preserving a zero count when advancing a closed or exhausted stream. Add seven in-memory regression/control cases covering unread, one-byte, fully consumed and STORED entries, partial final-entry reads, and closed streams. This fixes the skipped-entry counter problem in COMPRESS-643; it does not require a partial-read compression ratio to equal the whole-entry ratio.

Validation on JDK 21 with the project's Java 8 compiler configuration:

  • Original production code: 67 ZIP tests, three expected assertion failures in the new regressions, zero errors.

  • Patched production code: all 67 ZIP tests pass.

  • Default mvn -B -ntp: BUILD SUCCESS; Surefire reports 4788 tests, zero failures/errors, 29 pre-existing skipped tests (4759 passed). No additional skips or test exclusions were added.

  • A separate six-case in-memory reproduction also passes against the patched classes.

  • Read the contribution guidelines.

  • Read the ASF Generative Tooling Guidance.

  • AI was used: DeepSeek assisted with diagnosis, test and fix generation, and first-pass review. Codex coordinated the work, corrected and reviewed the patch, independently ran the native validation, and prepared this description. The commit includes Assisted-By trailers. No human review is claimed.

  • Run a successful build using the default Maven goal.

  • Add behavioral tests that fail against the original production code.

  • Describe the problem, resulting behavior, and validation.

  • Use a meaningful commit message containing the existing Jira key.

Reset the uncompressed byte count after closing the previous entry so
implicit draining does not leak its unread bytes into the next count.
Preserve the zero count when advancing a closed or exhausted stream.

Add DEFLATED data-descriptor regressions plus fully consumed, STORED,
partial final entry, and closed-stream controls.

Assisted-By: DeepSeek (deepseek-flash)
Assisted-By: Codex

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't edit changes.xml.

Remove the changes.xml entry as requested in review5843396090.
The ZIP reader fix and its regression tests are unchanged.

Assisted-By: Codex
@hutiefang76

Copy link
Copy Markdown
Author

Removed the changes.xml entry in 06770b6. The PR now contains only the ZIP reader fix and its regression tests. The default Maven build passes again: 4788 reported tests, 4759 passed and 29 existing skips, with zero failures or errors.

AI-assisted update.

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.

2 participants