Skip to content

Commit 6c1713d

Browse files
committed
Prevent NPE by checking if the stream has any bytes available
1 parent ad326f3 commit 6c1713d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/com.tw.go.config.json/JsonConfigParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public static JsonElement parseStream(JsonConfigCollection result, InputStream i
2626

2727
public static JsonElement parseStream(JsonConfigCollection result, JsonConfigParser parser, InputStream input, String location) {
2828
try (InputStreamReader contentReader = new InputStreamReader(input)) {
29+
if (input.available() < 1) {
30+
result.addError(new PluginError("File is empty", location));
31+
return null;
32+
}
33+
2934
JsonElement el = parser.parse(contentReader);
3035

3136
if (el == null || el.isJsonNull()) {

0 commit comments

Comments
 (0)