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
This commit is contained in:
parent
b8a1043e98
commit
07cd67a3fe
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue