22
33import java .io .IOException ;
44import java .io .InputStream ;
5+ import java .time .DateTimeException ;
56import java .time .OffsetDateTime ;
67import java .time .format .DateTimeFormatter ;
78import java .time .format .DateTimeParseException ;
@@ -23,15 +24,19 @@ public class BuildInfo {
2324
2425 static {
2526 try (InputStream is = BuildInfo .class .getResourceAsStream ("/version.properties" )) {
26- Properties versionProps = new Properties ();
27- versionProps .load (is );
28- properties .putAll (versionProps );
27+ if (is != null ) {
28+ Properties versionProps = new Properties ();
29+ versionProps .load (is );
30+ properties .putAll (versionProps );
31+ }
2932 } catch (IOException ignored ) {
3033 }
3134 try (InputStream is = BuildInfo .class .getResourceAsStream ("/openapi-generator-git.properties" )) {
32- Properties gitProps = new Properties ();
33- gitProps .load (is );
34- properties .putAll (gitProps );
35+ if (is != null ) {
36+ Properties gitProps = new Properties ();
37+ gitProps .load (is );
38+ properties .putAll (gitProps );
39+ }
3540 } catch (IOException ignored ) {
3641 }
3742 }
@@ -82,7 +87,13 @@ public String versionDisplayText() {
8287 StringBuilder sb = new StringBuilder (CLI_NAME );
8388 sb .append (" " ).append (this .getVersion ()).append (System .lineSeparator ());
8489 sb .append (" commit : " ).append (this .getSha ()).append (System .lineSeparator ());
85- sb .append (" built : " ).append (this .getBuildTime ().format (DateTimeFormatter .ISO_OFFSET_DATE_TIME )).append (System .lineSeparator ());
90+ sb .append (" built : " );
91+ try {
92+ sb .append (this .getBuildTime ().format (DateTimeFormatter .ISO_OFFSET_DATE_TIME ));
93+ } catch (DateTimeException e ) {
94+ sb .append (UNKNOWN );
95+ }
96+ sb .append (System .lineSeparator ());
8697 sb .append (" source : " ).append (GIT_REPO ).append (System .lineSeparator ());
8798 sb .append (" docs : " ).append (SITE ).append (System .lineSeparator ());
8899 return sb .toString ();
0 commit comments