Skip to content

Commit

Permalink
Merge pull request #50 from pylerSM/patch-4
Browse files Browse the repository at this point in the history
Handle bad hosts
  • Loading branch information
javiersantos authored Aug 27, 2016
2 parents 87732c0 + 62bb599 commit f809825
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f809825

Please sign in to comment.