2
2
3
3
import java .io .IOException ;
4
4
import java .io .InputStream ;
5
+ import java .time .DateTimeException ;
5
6
import java .time .OffsetDateTime ;
6
7
import java .time .format .DateTimeFormatter ;
7
8
import java .time .format .DateTimeParseException ;
@@ -23,15 +24,19 @@ public class BuildInfo {
23
24
24
25
static {
25
26
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
+ }
29
32
} catch (IOException ignored ) {
30
33
}
31
34
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
+ }
35
40
} catch (IOException ignored ) {
36
41
}
37
42
}
@@ -82,7 +87,13 @@ public String versionDisplayText() {
82
87
StringBuilder sb = new StringBuilder (CLI_NAME );
83
88
sb .append (" " ).append (this .getVersion ()).append (System .lineSeparator ());
84
89
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 ());
86
97
sb .append (" source : " ).append (GIT_REPO ).append (System .lineSeparator ());
87
98
sb .append (" docs : " ).append (SITE ).append (System .lineSeparator ());
88
99
return sb .toString ();
0 commit comments