[475763] Update Cache preference values only when valid
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java
index 0670efe..d459115 100644
--- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java
+++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java
@@ -221,12 +221,12 @@
 	    	  return cacheEntry;
 	    	}
 		    Random rand = new Random();
-			String fileName = rand.nextInt() + CACHE_EXTENSION;
+			String fileName = Math.abs(rand.nextInt()) + CACHE_EXTENSION;
 		    File file = new File(cacheLocation, fileName);
 		    // If the file already exists we need to change the file name.
 		    while(!file.createNewFile())
 		    {
-			  fileName = rand.nextInt() + CACHE_EXTENSION;
+			  fileName = Math.abs(rand.nextInt()) + CACHE_EXTENSION;
 			  file = new File(cacheLocation,fileName);
 		    }
 		    os = new BufferedOutputStream(new FileOutputStream(file));
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java
index ac92b58..bee514c 100644
--- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java
+++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/preferences/CachePreferencePage.java
@@ -209,7 +209,6 @@
 			public void modifyText(ModifyEvent e) {
 				try {
 					long newTimeout = Long.parseLong(cacheDuration.getText());
-					CachePlugin.getDefault().setCacheTimeout(newTimeout);
 
 					if (newTimeout < 1) {
 						setValid(newTimeout > 0);
@@ -218,6 +217,7 @@
 					else {
 						setValid(true);
 						setErrorMessage(null);
+						CachePlugin.getDefault().setCacheTimeout(newTimeout);
 					}
 				}
 				catch (NumberFormatException e1) {