This is an automated email from the ASF dual-hosted git repository. jamesbognar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push: new 9c0a06d Minor Config API fixes. 9c0a06d is described below commit 9c0a06d4ace9752c1cf305f6808dfb36516feb81 Author: JamesBognar <jamesbog...@apache.org> AuthorDate: Tue Apr 24 20:18:00 2018 -0400 Minor Config API fixes. --- .../org/apache/juneau/config/internal/ConfigMap.java | 16 +++++++--------- .../java/org/apache/juneau/config/ConfigMapTest.java | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/internal/ConfigMap.java b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/internal/ConfigMap.java index 03e9409..0f6e306 100644 --- a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/internal/ConfigMap.java +++ b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/internal/ConfigMap.java @@ -82,13 +82,11 @@ public class ConfigMap implements ConfigStoreListener { while (scanner.hasNextLine()) { String line = scanner.nextLine(); char c = firstChar(line); - if (c != 0 || c != '#') { - if (c == '[') { - int c2 = StringUtils.lastNonWhitespaceChar(line); - String l = line.trim(); - if (c2 != ']' || ! isValidNewSectionName(l.substring(1, l.length()-1))) - throw new ConfigException("Invalid section name found in configuration: {0}", line) ; - } + if (c == '[') { + int c2 = StringUtils.lastNonWhitespaceChar(line); + String l = line.trim(); + if (c2 != ']' || ! isValidNewSectionName(l.substring(1, l.length()-1))) + throw new ConfigException("Invalid section name found in configuration: {0}", line) ; } lines.add(line); } @@ -117,7 +115,7 @@ public class ConfigMap implements ConfigStoreListener { String accumulator = null; while (li.hasPrevious()) { String l = li.previous(); - char c = l.isEmpty() ? 0 : l.charAt(0); + char c = firstChar(l); if (c == '\t') { c = firstNonWhitespaceChar(l); if (c != '#') { @@ -143,7 +141,7 @@ public class ConfigMap implements ConfigStoreListener { for (int i = last; i >= 0; i--) { String l = lines.get(i); - char c = StringUtils.firstNonWhitespaceChar(l); + char c = firstChar(l); if (state == S1) { if (c == '[') { diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/config/ConfigMapTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/config/ConfigMapTest.java index 2840125..a686cbf 100644 --- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/config/ConfigMapTest.java +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/config/ConfigMapTest.java @@ -261,17 +261,17 @@ public class ConfigMapTest { public void testMalformedSectionHeaders() throws Exception { String[] test = { - "[]", "[ ]", " [ ] ", "\t[\t\t]\t", + "[]", "[ ]", "[/]", "[[]", "[]]", "[\\]", "[foo/bar]", "[foo[bar]", "[foo]bar]", "[foo\\bar]", - "[]", "[ ]", "[\t]", " [] ", + "[]", "[ ]", "[\t]", }; for (String t : test) { ConfigStore s = initStore("Foo.cfg", t); try { s.getMap("Foo.cfg"); - fail("Exception expected."); + fail("Exception expected on t=["+t+"]."); } catch (ConfigException e) { assertTrue(e.getLocalizedMessage().startsWith("Invalid section name")); } -- To stop receiving notification emails like this one, please contact jamesbog...@apache.org.