From 3fd1050cc49a462ebe956ffaac7ea6b866bbeb9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 15 Oct 2010 22:49:11 +0200 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20crash=20on=20parsing=20incorrect?= =?utf8?q?=20XML.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/core/SoneDownloader.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index 4dd634c..a36c17a 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -137,7 +137,14 @@ public class SoneDownloader extends AbstractService { xmlBucket = fetchResult.asBucket(); xmlInputStream = xmlBucket.getInputStream(); Document document = XML.transformToDocument(xmlInputStream); - SimpleXML soneXml = SimpleXML.fromDocument(document); + SimpleXML soneXml; + try { + soneXml = SimpleXML.fromDocument(document); + } catch (NullPointerException npe1) { + /* for some reason, invalid XML can cause NPEs. */ + logger.log(Level.WARNING, "XML for Sone " + sone + " can not be parsed!", npe1); + return; + } /* check ID. */ String soneId = soneXml.getValue("id", null); -- 2.7.4