Commit 07cd67a3 authored by Stephane Nicoll's avatar Stephane Nicoll

Tolerate null startTime

This commit prevents a potential NPE if the startTime of the
MavenSession is not available and fallbacks to the current time. This
can happen when invoking the plugin with Maven embedded in an IDE.

Closes gh-17810
parent b8a1043e
......@@ -18,6 +18,7 @@ package org.springframework.boot.maven;
import java.io.File;
import java.time.Instant;
import java.util.Date;
import java.util.Map;
import org.apache.maven.execution.MavenSession;
......@@ -100,7 +101,8 @@ public class BuildInfoMojo extends AbstractMojo {
private Instant getBuildTime() {
if (this.time == null || this.time.isEmpty()) {
return this.session.getRequest().getStartTime().toInstant();
Date startTime = this.session.getRequest().getStartTime();
return (startTime != null) ? startTime.toInstant() : Instant.now();
}
if ("off".equalsIgnoreCase(this.time)) {
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment