From 5cc4f299b2a1138687cbaea73257abab08e245a4 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Sat, 04 Jun 2011 14:23:55 -0400 Subject: [PATCH] Fixed refs linking problem. Author metrics are lowercase. --- src/com/gitblit/FileSettings.java | 36 +++++++++++++++++++++++++++--------- 1 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/com/gitblit/FileSettings.java b/src/com/gitblit/FileSettings.java index 04430a5..01176c0 100644 --- a/src/com/gitblit/FileSettings.java +++ b/src/com/gitblit/FileSettings.java @@ -21,6 +21,7 @@ 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,17 @@ */ public class FileSettings implements IStoredSettings { + private final Logger logger = LoggerFactory.getLogger(FileSettings.class); + + private final File propertiesFile; + private Properties properties = new Properties(); - private long lastread = 0; + private long lastread; - private final Logger logger = LoggerFactory.getLogger(FileSettings.class); + public FileSettings(String file) { + this.propertiesFile = new File(file); + } @Override public List<String> getAllKeys(String startingWith) { @@ -131,28 +138,39 @@ strings.add(chunk); } } - } catch (Exception e) { + } catch (PatternSyntaxException e) { + logger.error("Failed to parse " + value, e); } return strings; } private synchronized Properties read() { - File file = new File(Constants.PROPERTIES_FILE); - if (file.exists() && (file.lastModified() > lastread)) { + if (propertiesFile.exists() && (propertiesFile.lastModified() > lastread)) { + FileInputStream is = null; try { properties = new Properties(); - properties.load(new FileInputStream(Constants.PROPERTIES_FILE)); - lastread = file.lastModified(); + is = new FileInputStream(propertiesFile); + properties.load(is); + lastread = propertiesFile.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(); + return propertiesFile.getAbsolutePath(); } } -- Gitblit v1.9.1