summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/FileSettings.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-05-26 17:11:38 -0400
committerJames Moger <james.moger@gitblit.com>2011-05-26 17:11:38 -0400
commit2a7306a1d92522569a8bb6e5a7c0bcdd5cf4cfaa (patch)
treeb9bc648068b0af5cbbbc3e2e0ad707e0c59d4db2 /src/com/gitblit/FileSettings.java
parentf13c4c5a35a18d8478b276cc44570bbc3398aa73 (diff)
downloadgitblit-2a7306a1d92522569a8bb6e5a7c0bcdd5cf4cfaa.tar.gz
gitblit-2a7306a1d92522569a8bb6e5a7c0bcdd5cf4cfaa.zip
Findbugs. CodePro Audit. Checkstyle. Unit test refactoring.
Diffstat (limited to 'src/com/gitblit/FileSettings.java')
-rw-r--r--src/com/gitblit/FileSettings.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/com/gitblit/FileSettings.java b/src/com/gitblit/FileSettings.java
index 04430a59..e6fb9398 100644
--- a/src/com/gitblit/FileSettings.java
+++ b/src/com/gitblit/FileSettings.java
@@ -21,6 +21,7 @@ import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import java.util.regex.PatternSyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,11 +32,11 @@ import org.slf4j.LoggerFactory;
*/
public class FileSettings implements IStoredSettings {
- private Properties properties = new Properties();
+ private final Logger logger = LoggerFactory.getLogger(FileSettings.class);
- private long lastread = 0;
+ private Properties properties = new Properties();
- private final Logger logger = LoggerFactory.getLogger(FileSettings.class);
+ private long lastread;
@Override
public List<String> getAllKeys(String startingWith) {
@@ -131,7 +132,8 @@ public class FileSettings implements IStoredSettings {
strings.add(chunk);
}
}
- } catch (Exception e) {
+ } catch (PatternSyntaxException e) {
+ logger.error("Failed to parse " + value, e);
}
return strings;
}
@@ -139,18 +141,29 @@ public class FileSettings implements IStoredSettings {
private synchronized Properties read() {
File file = new File(Constants.PROPERTIES_FILE);
if (file.exists() && (file.lastModified() > lastread)) {
+ FileInputStream is = null;
try {
properties = new Properties();
- properties.load(new FileInputStream(Constants.PROPERTIES_FILE));
+ is = new FileInputStream(Constants.PROPERTIES_FILE);
+ properties.load(is);
lastread = file.lastModified();
} catch (FileNotFoundException f) {
+ // IGNORE - won't happen because file.exists() check above
} catch (Throwable t) {
t.printStackTrace();
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (Throwable t) {
+ // IGNORE
+ }
+ }
}
}
return properties;
}
-
+
@Override
public String toString() {
return new File(Constants.PROPERTIES_FILE).getAbsolutePath();