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

Unpacking jared source code fails on unix time negative value #354

Closed
spacetom opened this issue Oct 23, 2024 · 1 comment
Closed

Unpacking jared source code fails on unix time negative value #354

spacetom opened this issue Oct 23, 2024 · 1 comment

Comments

@spacetom
Copy link

spacetom commented Oct 23, 2024

When unpacking source code using maven-dependency-plugin the action fails for some libraries. The issue happens when there are files containing entries with last modified time before initial value of unix time (1970-01-01T00:00). When such time is turned into unix time it gets negative value and later on when the value is passed to File.setLastModified() the method throws IllegalArgumentException("Negative time"). The issue happens for library version 4.10.0 AbstractUnArchiver class at line 328. Exemplary library containing such entries is /net/minidev/json-smart/2.5.1/json-smart-2.5.1-sources.jar.

Possible fix might be:

            long time = entryDate.getTime();
            if (time < 0) {
                getLogger().warn("File {} contains entry {} with negative last modified time {}" +
                    " Replacing it with 0.", srcF.getPath(), entryName, time);
                time = 0;
            }
            targetFileName.setLastModified(time);
@spacetom
Copy link
Author

Duplicate of #170

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

No branches or pull requests

1 participant