Skip to content

Commit 15531fb

Browse files
committed
[MNG-5729] Fix possible NPE with introduction of mononic clock
1 parent 50aecc7 commit 15531fb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

impl/maven-cli/src/main/java/org/apache/maven/cling/event/ExecutionEventLogger.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import java.time.Duration;
2424
import java.time.Instant;
2525
import java.time.ZoneId;
26+
import java.time.ZonedDateTime;
27+
import java.time.temporal.ChronoUnit;
2628
import java.util.List;
2729
import java.util.Objects;
2830

@@ -278,7 +280,8 @@ private void logStats(MavenSession session) {
278280

279281
logger.info("Total time: {}{}", formatDuration(time), wallClock);
280282

281-
logger.info("Finished at: {}", formatTimestamp(finish.atZone(ZoneId.systemDefault())));
283+
ZonedDateTime rounded = finish.truncatedTo(ChronoUnit.SECONDS).atZone(ZoneId.systemDefault());
284+
logger.info("Finished at: {}", formatTimestamp(rounded));
282285
}
283286

284287
@Override

impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ protected void stop() {
927927
}
928928

929929
protected Duration wallTime() {
930-
return Duration.between(start, end);
930+
return start != null && end != null ? Duration.between(start, end) : Duration.ZERO;
931931
}
932932

933933
protected Duration execTime() {

0 commit comments

Comments
 (0)