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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0ec85b0  TEXT-210: fixing spotbugs failures
0ec85b0 is described below

commit 0ec85b01b043e0d838e706d14b0cd1d21dc48d54
Author: Matt Juntunen <[email protected]>
AuthorDate: Tue Jul 6 22:36:25 2021 -0400

    TEXT-210: fixing spotbugs failures
---
 spotbugs-exclude-filter.xml                                        | 7 +++++++
 src/main/java/org/apache/commons/text/ExtendedMessageFormat.java   | 6 +++++-
 .../java/org/apache/commons/text/io/StringSubstitutorReader.java   | 3 +--
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/spotbugs-exclude-filter.xml b/spotbugs-exclude-filter.xml
index 44baec8..26a541e 100644
--- a/spotbugs-exclude-filter.xml
+++ b/spotbugs-exclude-filter.xml
@@ -23,6 +23,13 @@
   </Match>
 
   <Match>
+    <!-- False positives in regard to Locale property exposing inner 
implementation
+    details of class. However, Locale is not mutable and therefore safe in 
this context. -->
+    <Class name="org.apache.commons.text.similarity.FuzzyScore" />
+    <Bug code="EI,EI2" />
+  </Match>
+
+  <Match>
     <Class name="org.apache.commons.text.StrTokenizer" />
     <Method name="clone" />
     <Bug code="CN" />
diff --git a/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java 
b/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
index f24efb7..56ad987 100644
--- a/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
+++ b/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
@@ -21,6 +21,8 @@ import java.text.MessageFormat;
 import java.text.ParsePosition;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Locale.Category;
@@ -160,7 +162,9 @@ public class ExtendedMessageFormat extends MessageFormat {
                                  final Map<String, ? extends FormatFactory> 
registry) {
         super(DUMMY_PATTERN);
         setLocale(locale);
-        this.registry = registry;
+        this.registry = registry != null
+                ? Collections.unmodifiableMap(new HashMap<>(registry))
+                : null;
         applyPattern(pattern);
     }
 
diff --git 
a/src/main/java/org/apache/commons/text/io/StringSubstitutorReader.java 
b/src/main/java/org/apache/commons/text/io/StringSubstitutorReader.java
index f5a26d9..8f17ba8 100644
--- a/src/main/java/org/apache/commons/text/io/StringSubstitutorReader.java
+++ b/src/main/java/org/apache/commons/text/io/StringSubstitutorReader.java
@@ -20,7 +20,6 @@ package org.apache.commons.text.io;
 import java.io.FilterReader;
 import java.io.IOException;
 import java.io.Reader;
-import java.util.Objects;
 
 import org.apache.commons.text.StringSubstitutor;
 import org.apache.commons.text.TextStringBuilder;
@@ -73,7 +72,7 @@ public class StringSubstitutorReader extends FilterReader {
      */
     public StringSubstitutorReader(final Reader reader, final 
StringSubstitutor stringSubstitutor) {
         super(reader);
-        this.stringSubstitutor = Objects.requireNonNull(stringSubstitutor);
+        this.stringSubstitutor = new StringSubstitutor(stringSubstitutor);
         this.prefixEscapeMatcher = 
StringMatcherFactory.INSTANCE.charMatcher(stringSubstitutor.getEscapeChar())
             .andThen(stringSubstitutor.getVariablePrefixMatcher());
     }

Reply via email to