You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/08/14 05:44:16 UTC

[commons-text] branch master updated (517dc76 -> 3c4d37d)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git.


    from 517dc76  Merge pull request #147 from apache/dependabot/github_actions/actions/setup-java-v1.4.1
     new a951919  Sort methods.
     new 3c4d37d  [TEXT-186] StringSubstitutor map constructor throws NPE on 1.9 with null map.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  3 +-
 .../commons/text/lookup/FunctionStringLookup.java  |  3 +-
 .../apache/commons/text/StringSubstitutorTest.java | 32 +++++++++++++---------
 3 files changed, 23 insertions(+), 15 deletions(-)


[commons-text] 01/02: Sort methods.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit a95191994a0503ba311f02a41b21dabe4167d7b7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Aug 14 01:34:31 2020 -0400

    Sort methods.
---
 .../apache/commons/text/StringSubstitutorTest.java | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
index 3c23b23..f7301b5 100644
--- a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
+++ b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
@@ -254,31 +254,31 @@ public class StringSubstitutorTest {
      * Tests interpolation with weird boundary patterns.
      */
     @Test
-    public void testReplace_JiraText178_WeirdPatterns2() throws IOException {
-        doReplace("${1}", "$${${a}}", false);
+    public void testReplace_JiraText178_WeirdPatterns1() throws IOException {
+        doNotReplace("$${");
+        doNotReplace("$${a");
+        doNotReplace("$$${");
+        doNotReplace("$$${a");
+        doNotReplace("$${${a");
+        doNotReplace("${${a}"); // "${a" is not a registered variable name.
+        doNotReplace("${$${a}");
     }
 
     /**
      * Tests interpolation with weird boundary patterns.
      */
     @Test
-    @Disabled
-    public void testReplace_JiraText178_WeirdPatterns3() throws IOException {
-        doReplace("${${a}", "$${${a}", false); // not "$${1" or "${1"
+    public void testReplace_JiraText178_WeirdPatterns2() throws IOException {
+        doReplace("${1}", "$${${a}}", false);
     }
 
     /**
      * Tests interpolation with weird boundary patterns.
      */
     @Test
-    public void testReplace_JiraText178_WeirdPatterns1() throws IOException {
-        doNotReplace("$${");
-        doNotReplace("$${a");
-        doNotReplace("$$${");
-        doNotReplace("$$${a");
-        doNotReplace("$${${a");
-        doNotReplace("${${a}"); // "${a" is not a registered variable name.
-        doNotReplace("${$${a}");
+    @Disabled
+    public void testReplace_JiraText178_WeirdPatterns3() throws IOException {
+        doReplace("${${a}", "$${${a}", false); // not "$${1" or "${1"
     }
 
     /**


[commons-text] 02/02: [TEXT-186] StringSubstitutor map constructor throws NPE on 1.9 with null map.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 3c4d37d68a18aa5c93b95f27645c7589c58e54e8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Aug 14 01:44:06 2020 -0400

    [TEXT-186] StringSubstitutor map constructor throws NPE on 1.9 with null
    map.
---
 src/changes/changes.xml                                             | 3 ++-
 .../java/org/apache/commons/text/lookup/FunctionStringLookup.java   | 3 ++-
 src/test/java/org/apache/commons/text/StringSubstitutorTest.java    | 6 ++++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e07244a..8c410c7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -45,7 +45,8 @@ The <action> type attribute can be add,update,fix,remove.
   </properties>
   <body>
   <release version="1.9.1" date="202Y-MM-DD" description="Release 1.9.1. Requires Java 8.">
-    <action issue="TEXT-158" type="fix" dev="kinow">Incorrect values for Jaccard similarity with empty strings</action>
+    <action issue="TEXT-158" type="fix" dev="kinow">Incorrect values for Jaccard similarity with empty strings.</action>
+    <action issue="TEXT-186" type="fix" dev="ggregory" due-to="Gautam Korlam, Gary Gregory">StringSubstitutor map constructor throws NPE on 1.9 with null map.</action>
     <action issue="TEXT-185" type="add" dev="ggregory" due-to="Larry West, Gary Gregory">Release Notes page hasn't been updated for 1.9 release yet.</action>    
     <action                  type="add" dev="ggregory" due-to="Gary Gregory, Dependabot">Update spotbugs.plugin.version 4.0.0 to 4.1.1, #144.</action>
     <action                  type="add" dev="ggregory" due-to="Dependabot">Update mockito-inline from 3.4.4 to 3.4.6 #143.</action>
diff --git a/src/main/java/org/apache/commons/text/lookup/FunctionStringLookup.java b/src/main/java/org/apache/commons/text/lookup/FunctionStringLookup.java
index ba158fc..50dd18d 100644
--- a/src/main/java/org/apache/commons/text/lookup/FunctionStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/FunctionStringLookup.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.text.lookup;
 
+import java.util.Collections;
 import java.util.Map;
 import java.util.Objects;
 import java.util.function.Function;
@@ -48,7 +49,7 @@ final class FunctionStringLookup<V> extends AbstractStringLookup {
      * @return a new instance backed by the given map.
      */
     static <V> FunctionStringLookup<V> on(final Map<String, V> map) {
-        return on(map::get);
+        return on((map == null ? Collections.<String, V>emptyMap() : map)::get);
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
index f7301b5..368440c 100644
--- a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
+++ b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
@@ -202,6 +202,12 @@ public class StringSubstitutorTest {
     }
 
     @Test
+    public void testConstructorNullMap() {
+        Map<String, Object> parameters = null;
+        final StringSubstitutor s = new StringSubstitutor(parameters, "prefix", "suffix");
+    }
+
+    @Test
     public void testConstructorStringSubstitutor() {
         final StringSubstitutor source = new StringSubstitutor();
         source.setDisableSubstitutionInValues(true);