changeset 1599:3570aec27794

CommonPaths should not create directories as a side-effect of instantiation reviewed-by: jerboaa review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-December/011977.html Fixes PR1638 CommonPaths used to create whichever directories were missing. An earlier change moved that responsibility to a separate class, but one File.mkdirs() call was accidentally left in constructor. It is not needed, it is now gone.
author Jon VanAlten <jon.vanalten@redhat.com>
date Wed, 03 Dec 2014 16:56:00 -0700
parents 98f306902db6
children 0f55b554d197
files config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java config/src/main/java/com/redhat/thermostat/shared/locale/internal/LocaleResources.java config/src/main/resources/com/redhat/thermostat/shared/locale/internal/strings.properties
diffstat 3 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java	Fri Dec 05 12:55:53 2014 -0500
+++ b/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java	Wed Dec 03 16:56:00 2014 -0700
@@ -119,7 +119,7 @@
         }
         this.systemHome = new File(home);
         if (!systemHome.exists()) {
-            systemHome.mkdirs();
+            throw new InvalidConfigurationException(t.localize(LocaleResources.SYSHOME_DOESNT_EXIST, home));
         }
         if (!systemHome.isDirectory()) {
             throw new InvalidConfigurationException(t.localize(LocaleResources.SYSHOME_NOT_A_DIR, home));
--- a/config/src/main/java/com/redhat/thermostat/shared/locale/internal/LocaleResources.java	Fri Dec 05 12:55:53 2014 -0500
+++ b/config/src/main/java/com/redhat/thermostat/shared/locale/internal/LocaleResources.java	Wed Dec 03 16:56:00 2014 -0700
@@ -41,6 +41,7 @@
 public enum LocaleResources {
 
     SYSHOME_NO_HOME,
+    SYSHOME_DOESNT_EXIST,
     SYSHOME_NOT_A_DIR,
     USERHOME_NOT_A_DIR,
     GENERAL_NOT_A_DIR,
--- a/config/src/main/resources/com/redhat/thermostat/shared/locale/internal/strings.properties	Fri Dec 05 12:55:53 2014 -0500
+++ b/config/src/main/resources/com/redhat/thermostat/shared/locale/internal/strings.properties	Wed Dec 03 16:56:00 2014 -0700
@@ -1,4 +1,5 @@
 SYSHOME_NO_HOME = THERMOSTAT_HOME not defined...
+SYSHOME_DOESNT_EXIST = THERMOSTAT_HOME is defined but does not exist: {0}
 SYSHOME_NOT_A_DIR = THERMOSTAT_HOME is defined but not a directory: {0}
 USERHOME_NOT_A_DIR = USER_THERMOSTAT_HOME is defined but not a directory: {0}
 GENERAL_NOT_A_DIR = Expecting directory, got other: {0}