Index: src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 8481)
+++ src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(working copy)
@@ -318,7 +318,7 @@
                 return true;
             }
 
-            HttpURLConnection urlConn = getURLConnection();
+            URLConnection urlConn = getURLConnection();
 
             if (isObjectLoadable()  &&
                     (now - attributes.getLastModification()) <= ABSOLUTE_EXPIRE_TIME_LIMIT) {
@@ -327,7 +327,7 @@
             if (isObjectLoadable() && attributes.getEtag() != null) {
                 urlConn.addRequestProperty("If-None-Match", attributes.getEtag());
             }
-            if (urlConn.getResponseCode() == 304) {
+            if (responseCode(urlConn) == 304) {
                 // If isModifiedSince or If-None-Match has been set
                 // and the server answers with a HTTP 304 = "Not Modified"
                 log.log(Level.FINE, "JCS - IfModifiedSince/Etag test: local version is up to date: {0}", getUrl());
@@ -348,15 +348,15 @@
             attributes = parseHeaders(urlConn);
 
             for (int i = 0; i < 5; ++i) {
-                if (urlConn.getResponseCode() == 503) {
+                if (responseCode(urlConn) == 503) {
                     Thread.sleep(5000+(new Random()).nextInt(5000));
                     continue;
                 }
 
-                attributes.setResponseCode(urlConn.getResponseCode());
+                attributes.setResponseCode(responseCode(urlConn));
                 byte[] raw = read(urlConn);
 
-                if (isResponseLoadable(urlConn.getHeaderFields(), urlConn.getResponseCode(), raw)) {
+                if (isResponseLoadable(urlConn.getHeaderFields(), responseCode(urlConn), raw)) {
                     // we need to check cacheEmpty, so for cases, when data is returned, but we want to store
                     // as empty (eg. empty tile images) to save some space
                     cacheData = createCacheEntry(raw);
@@ -521,4 +521,12 @@
     public void handleJobCancellation() {
         finishLoading(LoadResult.CANCELED);
     }
+
+    private int responseCode(URLConnection urlConn) throws IOException {
+        if (urlConn instanceof HttpURLConnection) {
+            return ((HttpURLConnection) urlConn).getResponseCode();
+        } else {
+            return 500;
+        }
+    }
 }
