-
Notifications
You must be signed in to change notification settings - Fork 300
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
Fix jarinfer cli output determinism #884
Conversation
30208f6
to
055e9d2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #884 +/- ##
============================================
+ Coverage 87.03% 87.09% +0.05%
- Complexity 1926 1940 +14
============================================
Files 77 77
Lines 6231 6267 +36
Branches 1212 1218 +6
============================================
+ Hits 5423 5458 +35
Misses 405 405
- Partials 403 404 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution! I have one comment
ZipEntry entry = new ZipEntry(jarEntry.getName()); | ||
entry.setTime(0); | ||
jarOS.putNextEntry(entry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extract these lines to a common private method and call it from all four places? And, in that method, can we add a comment as to why we do entry.setTime(0)
?
055e9d2
to
ea0fa4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
When invoking CLI, jar output sha is not constant. This breaks cacheability in build systems like Buck and Bazel.
Binary investigation (see attached screenshot) of these jars show byte 0xa-0xd in PkZip header is what is changes, and corresponds to file modified date/time (see https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html).
This PR is setting these times to 0 explicilty, so that jar sha remains constant between invokation.