Index: /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 8484)
+++ /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 8485)
@@ -90,5 +90,5 @@
                 t.setName(name);
                 return t;
-                }
+            }
         };
     }
@@ -319,5 +319,5 @@
             }
 
-            HttpURLConnection urlConn = getURLConnection();
+            URLConnection urlConn = getURLConnection();
 
             if (isObjectLoadable()  &&
@@ -328,5 +328,5 @@
                 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"
@@ -349,13 +349,13 @@
 
             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
@@ -386,4 +386,5 @@
         } catch (IOException e) {
             log.log(Level.FINE, "JCS - IOExecption during communication with server for: {0}", getUrl());
+
             attributes.setResponseCode(499); // set dummy error code
             boolean doCache = isResponseLoadable(null, 499, null) || cacheAsEmpty(); //generic 499 error code returned
@@ -448,6 +449,6 @@
     }
 
-    private HttpURLConnection getURLConnection() throws IOException {
-        HttpURLConnection urlConn = (HttpURLConnection) getUrl().openConnection();
+    private URLConnection getURLConnection() throws IOException {
+        URLConnection urlConn = getUrl().openConnection();
         urlConn.setRequestProperty("Accept", "text/html, image/png, image/jpeg, image/gif, */*");
         urlConn.setReadTimeout(readTimeout); // 30 seconds read timeout
@@ -463,9 +464,13 @@
 
     private boolean isCacheValidUsingHead() throws IOException {
-        HttpURLConnection urlConn = (HttpURLConnection) getUrl().openConnection();
-        urlConn.setRequestMethod("HEAD");
-        long lastModified = urlConn.getLastModified();
-        return (attributes.getEtag() != null && attributes.getEtag().equals(urlConn.getRequestProperty("ETag"))) ||
-               (lastModified != 0 && lastModified <= attributes.getLastModification());
+        URLConnection urlConn = getUrl().openConnection();
+        if(urlConn instanceof HttpURLConnection) {
+            ((HttpURLConnection)urlConn).setRequestMethod("HEAD");
+            long lastModified = urlConn.getLastModified();
+            return (attributes.getEtag() != null && attributes.getEtag().equals(urlConn.getRequestProperty("ETag"))) ||
+                    (lastModified != 0 && lastModified <= attributes.getLastModification());
+        }
+        // for other URL connections, do not use HEAD requests for cache validation
+        return false;
     }
 
@@ -522,3 +527,14 @@
         finishLoading(LoadResult.CANCELED);
     }
+
+    /*
+     * Temporary fix for file URLs. Returns response code for HttpURLConnections or 200 for all other
+     */
+    private int responseCode(URLConnection urlConn) throws IOException {
+        if (urlConn instanceof HttpURLConnection) {
+            return ((HttpURLConnection) urlConn).getResponseCode();
+        } else {
+            return 200;
+        }
+    }
 }
