From 17ae31a20e9ad1294bc8a872644d90d61a9dd890 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 27 Oct 2014 08:58:39 -0400
Subject: [PATCH] Adopt chain-loading properties as the default setup

---
 src/main/java/com/gitblit/FileSettings.java |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/gitblit/FileSettings.java b/src/main/java/com/gitblit/FileSettings.java
index 2f5f04f..3caf966 100644
--- a/src/main/java/com/gitblit/FileSettings.java
+++ b/src/main/java/com/gitblit/FileSettings.java
@@ -80,6 +80,7 @@
 		if (propertiesFile != null && propertiesFile.exists() && (forceReload || (propertiesFile.lastModified() > lastModified))) {
 			FileInputStream is = null;
 			try {
+				logger.debug("loading {}", propertiesFile);
 				Properties props = new Properties();
 				is = new FileInputStream(propertiesFile);
 				props.load(is);
@@ -124,8 +125,12 @@
 		if (!StringUtils.isEmpty(include)) {
 
 			// allow for multiples
-			List<String> names = StringUtils.getStringsFromValue(include, " ");
+			List<String> names = StringUtils.getStringsFromValue(include, ",");
 			for (String name : names) {
+
+				if (StringUtils.isEmpty(name)) {
+					continue;
+				}
 
 				// try co-located
 				File file = new File(propertiesFile.getParentFile(), name.trim());
@@ -134,16 +139,19 @@
 					file = new File(name.trim());
 				}
 
-				if (file.exists()) {
-					// load properties
-					try (FileInputStream iis = new FileInputStream(file)) {
-						baseProperties.load(iis);
-					}
-
-					// read nested includes
-					baseProperties = readIncludes(baseProperties);
-
+				if (!file.exists()) {
+					logger.warn("failed to locate {}", file);
+					continue;
 				}
+
+				// load properties
+				logger.debug("loading {}", file);
+				try (FileInputStream iis = new FileInputStream(file)) {
+					baseProperties.load(iis);
+				}
+
+				// read nested includes
+				baseProperties = readIncludes(baseProperties);
 
 			}
 
@@ -163,7 +171,7 @@
 		String content = FileUtils.readContent(propertiesFile, "\n");
 		for (String key : removals) {
 			String regex = "(?m)^(" + regExEscape(key) + "\\s*+=\\s*+)"
-				    + "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
+					+ "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
 			content = content.replaceAll(regex, "");
 		}
 		removals.clear();
@@ -183,7 +191,7 @@
 		String content = FileUtils.readContent(propertiesFile, "\n");
 		for (Map.Entry<String, String> setting:settings.entrySet()) {
 			String regex = "(?m)^(" + regExEscape(setting.getKey()) + "\\s*+=\\s*+)"
-				    + "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
+					+ "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
 			String oldContent = content;
 			content = content.replaceAll(regex, setting.getKey() + " = " + setting.getValue());
 			if (content.equals(oldContent)) {

--
Gitblit v1.9.1