-
Notifications
You must be signed in to change notification settings - Fork 41.6k
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
Remove unused SHA-1 hash from UNPACK markers #46520
Conversation
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>
f22845d to
3518a8e
Compare
|
We should probably update the runtime side of things as well: Lines 97 to 99 in 376ad32
Lines 112 to 114 in 376ad32
The @academey please don't make any changes to the PR just yet, I'd like to discuss with the team first. |
|
We discussed this today and want to use |
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. See gh-46520 Signed-off-by: Hyunjoon Choi <hyunjoon@example.com> Signed-off-by: academey <academey@gmail.com>
|
Thanks very much for the PR, @academey. |
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 theUNPACK:prefix is checked.Changes made:
StoredEntryPreparatorin bothBootZipCopyActionandAbstractJarWriterUNPACK:<sha1-hash>to simplyUNPACK: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