Index: /trunk/src/org/openstreetmap/josm/io/CacheFiles.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/CacheFiles.java	(revision 2015)
+++ /trunk/src/org/openstreetmap/josm/io/CacheFiles.java	(revision 2016)
@@ -55,23 +55,25 @@
      */
     public CacheFiles(String ident) {
-       String pref = Main.pref.getPluginsDirFile().getPath();
-       boolean dir_writeable;
-       this.ident = ident;
-       String cacheDir = Main.pref.get("cache." + ident + "." + "path", pref + "/" + ident + "/cache/");
-       this.dir = new File(cacheDir);
-       try {
-           this.dir.mkdirs();
-           dir_writeable = true;
+        String pref = Main.pref.getPluginsDirFile().getPath();
+        boolean dir_writeable;
+        this.ident = ident;
+        String cacheDir = Main.pref.get("cache." + ident + "." + "path", pref + "/" + ident + "/cache/");
+        this.dir = new File(cacheDir);
+        try {
+            this.dir.mkdirs();
+            dir_writeable = true;
         } catch(Exception e) {
-           // We have no access to this directory, so don't to anything
-           dir_writeable = false;
+            // We have no access to this directory, so don't do anything
+            dir_writeable = false;
         }
         this.enabled = dir_writeable;
         this.expire = Main.pref.getLong("cache." + ident + "." + "expire", EXPIRE_DAILY);
-        if(this.expire < 0)
+        if(this.expire < 0) {
             this.expire = CacheFiles.EXPIRE_NEVER;
+        }
         this.maxsize = Main.pref.getLong("cache." + ident + "." + "maxsize", 50);
-        if(this.maxsize < 0)
+        if(this.maxsize < 0) {
             this.maxsize = -1;
+        }
     }
 
@@ -94,6 +96,7 @@
 
             // Update last mod time so we don't expire recently used data
-            if(updateModTime)
+            if(updateModTime) {
                 data.setLastModified(new Date().getTime());
+            }
 
             byte[] bytes = new byte[(int) data.length()];
@@ -115,6 +118,7 @@
         try {
             File f = getPath(ident);
-            if(f.exists())
+            if(f.exists()) {
                 f.delete();
+            }
             // rws also updates the file meta-data, i.e. last mod time
             new RandomAccessFile(f, "rws").write(data);
@@ -144,6 +148,7 @@
             }
             // Update last mod time so we don't expire recently used images
-            if(updateModTime)
+            if(updateModTime) {
                 img.setLastModified(new Date().getTime());
+            }
             return ImageIO.read(img);
         } catch(Exception e) {
@@ -177,11 +182,10 @@
      */
     public void setExpire(int amount, boolean force) {
-        if(amount < 0)
-            this.expire = EXPIRE_NEVER;
-        else
-            this.expire = amount;
         String key = "cache." + ident + "." + "expire";
-        if(force || !Main.pref.hasKey(key))
-            Main.pref.putLong(key, this.expire);
+        if(Main.pref.hasKey(key) && !force)
+            return;
+
+        this.expire = amount > 0 ? amount : EXPIRE_NEVER;
+        Main.pref.putLong(key, this.expire);
     }
 
@@ -192,8 +196,10 @@
      */
     public void setMaxSize(int amount, boolean force) {
+        String key = "cache." + ident + "." + "maxsize";
+        if(Main.pref.hasKey(key) && !force)
+            return;
+
         this.maxsize = amount > 0 ? amount : -1;
-        String key = "cache." + ident + "." + "maxsize";
-        if(force || !Main.pref.hasKey(key))
-            Main.pref.putLong(key, this.maxsize);
+        Main.pref.putLong(key, this.maxsize);
     }
 
@@ -211,6 +217,7 @@
      */
     public void checkCleanUp() {
-        if(this.writes > this.cleanUpInterval)
+        if(this.writes > this.cleanUpInterval) {
             cleanUp();
+        }
     }
 
@@ -225,7 +232,7 @@
 
         for(File f : dir.listFiles()) {
-            if(isExpired(f))
+            if(isExpired(f)) {
                 f.delete();
-            else {
+            } else {
                 dirsize += f.length();
                 modtime.put(f.lastModified(), f);
@@ -259,16 +266,18 @@
     public void customCleanUp(int type, int size) {
         switch(type) {
-            case CLEAN_ALL:
-                for(File f : dir.listFiles())
+        case CLEAN_ALL:
+            for(File f : dir.listFiles()) {
+                f.delete();
+            }
+            break;
+        case CLEAN_SMALL_FILES:
+            for(File f: dir.listFiles())
+                if(f.length() < size) {
                     f.delete();
-                break;
-            case CLEAN_SMALL_FILES:
-                for(File f: dir.listFiles())
-                    if(f.length() < size)
-                        f.delete();
-                break;
-            case CLEAN_BY_DATE:
-                cleanUp();
-                break;
+                }
+            break;
+        case CLEAN_BY_DATE:
+            cleanUp();
+            break;
         }
     }
@@ -282,6 +291,7 @@
         long dirsize = 0;
 
-        for(File f : this.dir.listFiles())
+        for(File f : this.dir.listFiles()) {
             dirsize += f.length();
+        }
         return dirsize;
     }
