From: David ‘Bombe’ Roden Date: Wed, 23 Dec 2015 22:47:45 +0000 (+0100) Subject: Prevent potential NPE when configuration file is bad X-Git-Tag: 0.13^2~23 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4266791a920e19fd3b37992ee6656c34629a0028;p=jSite.git Prevent potential NPE when configuration file is bad --- diff --git a/src/main/java/de/todesbaum/jsite/main/Configuration.java b/src/main/java/de/todesbaum/jsite/main/Configuration.java index ea072d1..b0c7118 100644 --- a/src/main/java/de/todesbaum/jsite/main/Configuration.java +++ b/src/main/java/de/todesbaum/jsite/main/Configuration.java @@ -44,6 +44,7 @@ import de.todesbaum.jsite.application.Node; import de.todesbaum.jsite.application.Project; import de.todesbaum.jsite.main.ConfigurationLocator.ConfigurationLocation; import de.todesbaum.util.freenet.fcp2.PriorityClass; +import org.w3c.dom.Document; /** * The configuration. @@ -128,7 +129,10 @@ public class Configuration { StreamCopier.copy(fileInputStream, fileByteOutputStream, configurationFile.length()); fileByteOutputStream.close(); byte[] fileBytes = fileByteOutputStream.toByteArray(); - rootNode = SimpleXML.fromDocument(XML.transformToDocument(fileBytes)); + Document document = XML.transformToDocument(fileBytes); + if (document != null) { + rootNode = SimpleXML.fromDocument(document); + } return; } catch (FileNotFoundException e) { /* ignore. */