Skip to content

Commit c23aeb2

Browse files
authored
fix: null check for InputStream in ApiNameVersion (#161)
* fix: null check for InputStream in ApiNameVersion
1 parent 1a00d3e commit c23aeb2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/software/amazon/encryption/s3/internal/ApiNameVersion.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import software.amazon.awssdk.core.ApiName;
88

99
import java.io.IOException;
10+
import java.io.InputStream;
1011
import java.util.Properties;
1112
import java.util.function.Consumer;
1213

@@ -33,7 +34,15 @@ private static String apiVersion() {
3334
try {
3435
final Properties properties = new Properties();
3536
final ClassLoader loader = ApiNameVersion.class.getClassLoader();
36-
properties.load(loader.getResourceAsStream("project.properties"));
37+
38+
final InputStream inputStream = loader.getResourceAsStream("project.properties");
39+
// In some cases, e.g. native images, there is no way to load files,
40+
// and the inputStream returned is null.
41+
if (inputStream == null) {
42+
return API_VERSION_UNKNOWN;
43+
}
44+
45+
properties.load(inputStream);
3746
return properties.getProperty("version");
3847
} catch (final IOException ex) {
3948
return API_VERSION_UNKNOWN;

0 commit comments

Comments
 (0)