Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions components/formats-bsd/src/loci/formats/UpgradeChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
Expand Down Expand Up @@ -227,7 +228,7 @@ public boolean newVersionAvailable(String registryID, String caller) {
try {
// connect to the registry

URLConnection conn = new URL(query.toString()).openConnection();
HttpURLConnection conn = (HttpURLConnection) new URL(query.toString()).openConnection();
conn.setConnectTimeout(5000);
conn.setUseCaches(false);
conn.addRequestProperty("User-Agent", registryID);
Expand All @@ -248,12 +249,19 @@ public boolean newVersionAvailable(String registryID, String caller) {
// check if the string is not empty (upgrade available)

String result = sb.toString();
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
LOGGER.debug("Upgrade check failed: {}", result);
return false;
}
if (sb.length() == 0) {
LOGGER.debug("No update needed");
return false;
} else {
LOGGER.debug("UPGRADE AVAILABLE:" + result);
} else if (result.toLowerCase().indexOf("please upgrade") >= 0) {
LOGGER.debug("UPGRADE AVAILABLE: {}", result);
return true;
} else {
LOGGER.debug("Upgrade check not successful: {}", result);
return false;
}
}
catch (UnknownHostException e) {
Expand Down
Loading