Skip to content

Remove unused SHA-1 hash from UNPACK markers #46520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

academey
Copy link

This PR removes the unused SHA-1 hash calculation from UNPACK markers in the JAR/WAR packaging process.

Current behavior:
When creating executable JARs/WARs, Spring Boot calculates a SHA-1 hash for entries that require unpacking and appends it to the entry comment as UNPACK:<hash>. However, this hash is never used - only the UNPACK: prefix is checked.

Changes made:

  • Removed SHA-1 hash calculation from StoredEntryPreparator in both BootZipCopyAction and AbstractJarWriter
  • Changed the UNPACK comment from UNPACK:<sha1-hash> to simply UNPACK:
  • Updated tests to match the new format

Performance improvement:
This eliminates unnecessary file reads during packaging. Previously, files could be read up to 3 times (CRC calculation, SHA-1 hash, and actual copying). Removing the hash calculation reduces I/O operations and memory usage, especially beneficial for large libraries.

Fixes #46183

In BootZipCopyAction and AbstractJarWriter, SHA-1 hash is calculated for
stored entries requiring unpack and set as entry comment. However, the
hash isn't used anywhere, just the marker prefix 'UNPACK:' is checked.

This commit removes the unnecessary SHA-1 hash calculation which reads
the file completely in memory, potentially three times in extreme cases.
Now the comment is simply set to 'UNPACK:' without any hash, improving
performance.

Fixes spring-projectsgh-46183

Signed-off-by: Hyunjoon Choi <hyunjoon@example.com>
Signed-off-by: academey <academey@gmail.com>
@academey academey force-pushed the gh-46183-remove-unused-sha1-hash branch from f22845d to 3518a8e Compare July 23, 2025 23:40
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove unused SHA-1 hash from UNPACK markers of uber archive entries that require unpacking
2 participants