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..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,11 @@ 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; import javax.xml.parsers.SAXParser; @@ -50,8 +53,10 @@ public Update parse() { private InputStream getInputStream() { try { - return rssUrl.openConnection().getInputStream(); - } catch (FileNotFoundException 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) {