From d8d37fe406017fdfd753fd069c7208787a99318c Mon Sep 17 00:00:00 2001 From: 0xNF Date: Fri, 21 Sep 2012 09:56:12 -0400 Subject: [PATCH] Decided to get catch exceptions in ModuleSettings instead of throwing them. --- .../autopsy/coreutils/ModuleSettings.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/CoreUtils/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java b/CoreUtils/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java index 7397fed224..e960b0c3a7 100644 --- a/CoreUtils/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java +++ b/CoreUtils/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java @@ -113,13 +113,20 @@ public class ModuleSettings { * @return - the value associated with the setting. * @throws IOException */ - public static String getConfigSetting(String moduleName, String settingName) throws IOException{ + public static String getConfigSetting(String moduleName, String settingName){ if(configExists(moduleName)){ + try{ InputStream inputStream = new FileInputStream(getPropertyPath(moduleName)); Properties props = new Properties(); props.load(inputStream); inputStream.close(); return props.getProperty(settingName); + } + + catch(IOException e){ + Logger.getLogger(ModuleSettings.class.getName()).log(Level.WARNING, "Could not read config file [" + moduleName + "]", e); + return null; + } } else{ @@ -135,13 +142,15 @@ public class ModuleSettings { * @return - the map of all key:value pairs representing the settings of the config. * @throws IOException */ - public static Map< String, String> getConfigSettings(String moduleName) throws IOException { + public static Map< String, String> getConfigSettings(String moduleName) { if (configExists(moduleName)) { + try{ InputStream inputStream = new FileInputStream(getPropertyPath(moduleName)); Properties props = new Properties(); props.load(inputStream); inputStream.close(); + Set keys = props.stringPropertyNames(); Map map = new HashMap(); @@ -151,6 +160,11 @@ public class ModuleSettings { } return map; + } + catch(IOException e){ + Logger.getLogger(ModuleSettings.class.getName()).log(Level.WARNING, "Could not read config file [" + moduleName + "]", e); + return null; + } } else { makeConfigFile(moduleName);