File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
main/java/org/apache/maven/archiver
test/java/org/apache/maven/archiver Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -758,7 +758,13 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp
758
758
759
759
// Number representing seconds since the epoch
760
760
if (isNumeric (outputTimestamp )) {
761
- return Optional .of (Instant .ofEpochSecond (Long .parseLong (outputTimestamp )));
761
+ final Instant date = Instant .ofEpochSecond (Long .parseLong (outputTimestamp ));
762
+
763
+ if (date .isBefore (DATE_MIN ) || date .isAfter (DATE_MAX )) {
764
+ throw new IllegalArgumentException (
765
+ "'" + date + "' is not within the valid range " + DATE_MIN + " to " + DATE_MAX );
766
+ }
767
+ return Optional .of (date );
762
768
}
763
769
764
770
// no timestamp configured (1 character configuration is useful to override a full value during pom
Original file line number Diff line number Diff line change @@ -1342,9 +1342,6 @@ void testParseOutputTimestamp() {
1342
1342
1343
1343
assertThat (parseBuildOutputTimestamp ("1570300662" ).get ().getEpochSecond ())
1344
1344
.isEqualTo (1570300662L );
1345
- assertThat (parseBuildOutputTimestamp ("0" ).get ().getEpochSecond ()).isZero ();
1346
- assertThat (parseBuildOutputTimestamp ("1" ).get ().getEpochSecond ()).isEqualTo (1L );
1347
-
1348
1345
assertThat (parseBuildOutputTimestamp ("2019-10-05T18:37:42Z" ).get ().getEpochSecond ())
1349
1346
.isEqualTo (1570300662L );
1350
1347
assertThat (parseBuildOutputTimestamp ("2019-10-05T20:37:42+02:00" ).get ().getEpochSecond ())
@@ -1372,9 +1369,6 @@ void testEmptyParseOutputTimestampInstant(String value) {
1372
1369
1373
1370
@ ParameterizedTest
1374
1371
@ CsvSource ({
1375
- "0,0" ,
1376
- "1,1" ,
1377
- "9,9" ,
1378
1372
"1570300662,1570300662" ,
1379
1373
"2147483648,2147483648" ,
1380
1374
"2019-10-05T18:37:42Z,1570300662" ,
@@ -1410,6 +1404,9 @@ void testThrownParseOutputTimestampInstant(String outputTimestamp) {
1410
1404
@ ParameterizedTest
1411
1405
@ ValueSource (
1412
1406
strings = {
1407
+ "0" ,
1408
+ "1" ,
1409
+ "9" ,
1413
1410
"1980-01-01T00:00:01Z" ,
1414
1411
"2100-01-01T00:00Z" ,
1415
1412
"2100-02-28T23:59:59Z" ,
You can’t perform that action at this time.
0 commit comments