From 33e5903e8059468a0da2deffe3270198293cf853 Mon Sep 17 00:00:00 2001 From: Dietrich Travkin Date: Thu, 4 Apr 2024 17:52:10 +0200 Subject: [PATCH] Avoid NPE when a remote input stream cannot be read Avoids the following stacktrace: java.lang.NullPointerException at java.base/java.io.Reader.(Reader.java:168) at java.base/java.io.InputStreamReader.(InputStreamReader.java:88) at net.sourceforge.plantuml.utils.BlocLines.load(BlocLines.java:79) at net.sourceforge.plantuml.style.CommandStyleImport.executeArg(CommandStyleImport.java:89) --- src/net/sourceforge/plantuml/style/CommandStyleImport.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/net/sourceforge/plantuml/style/CommandStyleImport.java b/src/net/sourceforge/plantuml/style/CommandStyleImport.java index fe2f68f51..bdc6d5ab7 100644 --- a/src/net/sourceforge/plantuml/style/CommandStyleImport.java +++ b/src/net/sourceforge/plantuml/style/CommandStyleImport.java @@ -86,7 +86,9 @@ public class CommandStyleImport extends SingleLineCommand2 { if (path.startsWith("http://") || path.startsWith("https://")) { SURL url = SURL.create(path); try (InputStream remoteInputStream = url.openStream()) { - lines = BlocLines.load(remoteInputStream, location); + if (remoteInputStream != null) { + lines = BlocLines.load(remoteInputStream, location); + } } } else { final SFile styleFile = FileSystem.getInstance().getFile(path);