From 5f75033abfb7a79a5dfd832f71ee5e7facb0e2a7 Mon Sep 17 00:00:00 2001 From: pyler Date: Sat, 27 Aug 2016 13:56:17 +0200 Subject: [PATCH 1/2] Handle bad host https://github.com/javiersantos/AppUpdater/issues/37 --- .../java/com/github/javiersantos/appupdater/RssParser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/github/javiersantos/appupdater/RssParser.java b/library/src/main/java/com/github/javiersantos/appupdater/RssParser.java index 54063211..fba1d460 100644 --- a/library/src/main/java/com/github/javiersantos/appupdater/RssParser.java +++ b/library/src/main/java/com/github/javiersantos/appupdater/RssParser.java @@ -11,6 +11,7 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.net.UnknownHostException; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -51,7 +52,7 @@ public Update parse() { private InputStream getInputStream() { try { return rssUrl.openConnection().getInputStream(); - } catch (FileNotFoundException e) { + } catch (FileNotFoundException | UnknownHostException e) { Log.e("AppUpdater", "The XML updater file is invalid or is down. AppUpdate can't check for updates."); return null; } catch (IOException e) { From 62bb59995040b50dc2cf3c7c135a9638cbe9b87b Mon Sep 17 00:00:00 2001 From: pyler Date: Sat, 27 Aug 2016 14:01:44 +0200 Subject: [PATCH 2/2] Fixed another exception --- .../com/github/javiersantos/appupdater/RssParser.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/github/javiersantos/appupdater/RssParser.java b/library/src/main/java/com/github/javiersantos/appupdater/RssParser.java index fba1d460..1b393f89 100644 --- a/library/src/main/java/com/github/javiersantos/appupdater/RssParser.java +++ b/library/src/main/java/com/github/javiersantos/appupdater/RssParser.java @@ -9,8 +9,10 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.net.ConnectException; import java.net.MalformedURLException; import java.net.URL; +import java.net.URLConnection; import java.net.UnknownHostException; import javax.xml.parsers.ParserConfigurationException; @@ -51,8 +53,10 @@ public Update parse() { private InputStream getInputStream() { try { - return rssUrl.openConnection().getInputStream(); - } catch (FileNotFoundException | UnknownHostException e) { + URLConnection connection = rssUrl.openConnection(); + if (connection == null) return null; + return connection.getInputStream(); + } catch (FileNotFoundException | UnknownHostException | ConnectException e) { Log.e("AppUpdater", "The XML updater file is invalid or is down. AppUpdate can't check for updates."); return null; } catch (IOException e) {