Skip to content

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

Closed as not planned
@spacetom

Description

@spacetom

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions