[juneau] branch master updated: Minor fix in Config API.
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 7c6dda6 Minor fix in Config API. 7c6dda6 is described below commit 7c6dda6dd2e4479172f8ece8e2af53c09dc2ab46 Author: JamesBognarAuthorDate: Tue Apr 24 20:09:29 2018 -0400 Minor fix in Config API. --- .../src/main/java/org/apache/juneau/config/internal/ConfigMap.java| 4 ++-- 1 file changed, 2 insertions(+), 2 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 db48420..03e9409 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 @@ -81,7 +81,7 @@ public class ConfigMap implements ConfigStoreListener { try (Scanner scanner = new Scanner(contents)) { while (scanner.hasNextLine()) { String line = scanner.nextLine(); - char c = StringUtils.firstNonWhitespaceChar(line); + char c = firstChar(line); if (c != 0 || c != '#') { if (c == '[') { int c2 = StringUtils.lastNonWhitespaceChar(line); @@ -99,7 +99,7 @@ public class ConfigMap implements ConfigStoreListener { boolean foundComment = false; for (ListIterator li = lines.listIterator(); li.hasNext();) { String l = li.next(); - char c = firstChar(l); + char c = firstNonWhitespaceChar(l); if (c != '#') { if (c == 0 && foundComment) { li.set("[]"); -- To stop receiving notification emails like this one, please contact jamesbog...@apache.org.
[juneau] branch master updated: Minor bug fix in config API.
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 c3b4004 Minor bug fix in config API. c3b4004 is described below commit c3b4004fd884c29b56b835836c82bbfdd2dd542a Author: JamesBognarAuthorDate: Tue Apr 24 19:53:55 2018 -0400 Minor bug fix in config API. --- .../java/org/apache/juneau/config/internal/ConfigMap.java| 2 +- .../main/java/org/apache/juneau/internal/StringUtils.java| 12 2 files changed, 13 insertions(+), 1 deletion(-) 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 b2b3e72..db48420 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 @@ -99,7 +99,7 @@ public class ConfigMap implements ConfigStoreListener { boolean foundComment = false; for (ListIterator li = lines.listIterator(); li.hasNext();) { String l = li.next(); - char c = StringUtils.firstNonWhitespaceChar(l); + char c = firstChar(l); if (c != '#') { if (c == 0 && foundComment) { li.set("[]"); diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java index d7717a4..9ec58cc 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java @@ -2256,4 +2256,16 @@ public final class StringUtils { return Integer.MAX_VALUE; return s1.compareTo(s2); } + + /** +* Returns the first character in the specified string. +* +* @param s The string to check. +* @return The first character in the string, or 0 if the string is null or empty. +*/ + public static char firstChar(String s) { + if (s == null || s.length() == 0) + return 0; + return s.charAt(0); + } } -- To stop receiving notification emails like this one, please contact jamesbog...@apache.org.
[juneau] branch master updated: Minor Config API fixes.
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: JamesBognarAuthorDate: 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.
[juneau] branch master updated: Minor fix in RestClient.
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 8d0de97 Minor fix in RestClient. 8d0de97 is described below commit 8d0de97f8a86b688d91c2a4f216c9a1234cc2620 Author: JamesBognarAuthorDate: Tue Apr 24 20:37:22 2018 -0400 Minor fix in RestClient. --- .../src/main/java/org/apache/juneau/rest/client/RestClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java index 751163f..8bc4b24 100644 --- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java +++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java @@ -1009,7 +1009,7 @@ public class RestClient extends BeanContext implements Closeable { String url = rmm.getUrl(); String httpMethod = rmm.getHttpMethod(); - try (RestCall rc = doCall(httpMethod, url, httpMethod.equals("POST"))) { + try (RestCall rc = doCall(httpMethod, url, httpMethod.equals("POST") || httpMethod.equals("PUT"))) { rc.serializer(serializer).parser(parser); -- To stop receiving notification emails like this one, please contact jamesbog...@apache.org.