Skip to content

Commit

Permalink
Guard against null input stream (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalluck authored Aug 28, 2024
1 parent 8d452dc commit 7f40032
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -37,8 +38,8 @@
*/
@ApplicationScoped
public class ConfigProvider {

private static final Logger LOGGER = LoggerFactory.getLogger(ConfigProvider.class);

private static final String CONFIG_FILE = "custom_config.json";

private final BuildConfig config;
Expand All @@ -53,6 +54,7 @@ public ConfigProvider() throws IOException {
String customConfig = null;

try (InputStream is = getClass().getClassLoader().getResourceAsStream(CONFIG_FILE)) {
Objects.requireNonNull(is, "Input stream was null when getting resource " + CONFIG_FILE);
customConfig = new String(is.readAllBytes(), StandardCharsets.UTF_8);
LOGGER.debug("Found custom configuration: {}", customConfig);
} catch (IOException e) {
Expand Down

0 comments on commit 7f40032

Please sign in to comment.