Skip to content

ArtifactStoreFileSystem timestamp deserialization must be consistent #17

@or-shachar

Description

@or-shachar

While maven serialize timestamp to seconds granularity, the Artifact object holds timestamp with type "long" (epoch milliseconds).

To deserialize timestamp ArtifactStoreFileSystem uses GregorianCalendar (maybe cosnider moving to java8 time?), and sets it to the values it finds in the maven serialization.

Calendar cal = new GregorianCalendar();
cal.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
cal.set( Calendar.YEAR, Integer.parseInt( matcher.group( 2 ) ) );
cal.set( Calendar.MONTH, Integer.parseInt( matcher.group( 3 ) ) - 1 );
cal.set( Calendar.DAY_OF_MONTH, Integer.parseInt( matcher.group( 4 ) ) );
cal.set( Calendar.HOUR_OF_DAY, Integer.parseInt( matcher.group( 5 ) ) );
cal.set( Calendar.MINUTE, Integer.parseInt( matcher.group( 6 ) ) );
cal.set( Calendar.SECOND, Integer.parseInt( matcher.group( 7 ) ) );
long timestamp = cal.getTimeInMillis();
int buildNumber = Integer.parseInt( matcher.group( 8 ) );

Problem with this is that if we don't control the milliseconds as well we will get different Long value with each run of this code.

This might not affect most artifact stores but MemoryArtifactStore do expect timestamp match. It causes tests that uses MemoryArtifactStore to fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions