From d96897d5ae4f277c70a66bf96eccaa2edf31784b Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Thu, 25 Feb 2021 00:34:16 +0100 Subject: [PATCH] Fix NPE with no resource --- src/main/java/w2phtml/api/ConverterFactory.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/w2phtml/api/ConverterFactory.java b/src/main/java/w2phtml/api/ConverterFactory.java index 34ca0f8..e65c3a8 100644 --- a/src/main/java/w2phtml/api/ConverterFactory.java +++ b/src/main/java/w2phtml/api/ConverterFactory.java @@ -47,8 +47,10 @@ public class ConverterFactory { InputStream stream = loader.getResourceAsStream(propPath); String version = "Failed to get version"; try { - prop.load(stream); - version = (String) prop.get("releaseVersion"); + if (stream != null) { + prop.load(stream); + version = (String) prop.get("releaseVersion"); + } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -65,8 +67,10 @@ public class ConverterFactory { InputStream stream = loader.getResourceAsStream(propPath); String date = "Failed to get date"; try { - prop.load(stream); - date = (String) prop.get("releaseDate"); + if (stream != null) { + prop.load(stream); + date = (String) prop.get("releaseDate"); + } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace();