Skip to content
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

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

oliviernotteghem
Copy link
Contributor

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.

Screenshot 2023-12-21 at 10 35 42 AM

Copy link

codecov bot commented Dec 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5fbee1f) 87.03% compared to head (855bf13) 87.09%.
Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@msridhar msridhar left a 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

Comment on lines 227 to 229
ZipEntry entry = new ZipEntry(jarEntry.getName());
entry.setTime(0);
jarOS.putNextEntry(entry);
Copy link
Collaborator

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)?

Copy link
Collaborator

@msridhar msridhar left a 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!

@msridhar msridhar enabled auto-merge (squash) December 21, 2023 21:16
@msridhar msridhar merged commit ce41599 into uber:master Dec 21, 2023
10 checks passed
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