Avoid NPE when a remote input stream cannot be read

Avoids the following stacktrace:
java.lang.NullPointerException
	at java.base/java.io.Reader.<init>(Reader.java:168)
	at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:88)
	at net.sourceforge.plantuml.utils.BlocLines.load(BlocLines.java:79)
	at net.sourceforge.plantuml.style.CommandStyleImport.executeArg(CommandStyleImport.java:89)
This commit is contained in:
Dietrich Travkin 2024-04-04 17:52:10 +02:00
parent 7755ae5be4
commit 33e5903e80
1 changed files with 3 additions and 1 deletions

View File

@ -86,7 +86,9 @@ public class CommandStyleImport extends SingleLineCommand2<TitledDiagram> {
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);