Skip to content

Apache Lucene open-source search software

fix a small bug around these null checks

Mark Robert Millerc0e5935900ef
diff --git a/solr/core/src/java/org/apache/solr/update/processor/RegexReplaceProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/RegexReplaceProcessorFactory.java
index 29449df1738..98c23f527b5 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/RegexReplaceProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/RegexReplaceProcessorFactory.java
@@ -71,25 +71,26 @@ public final class RegexReplaceProcessorFactory extends FieldMutatingUpdateProce
@Override
public void init(NamedList args) {
- String patternParam = args.remove(PATTERN_PARAM).toString();
+ Object patternParam = args.remove(PATTERN_PARAM);
if(patternParam == null) {
throw new SolrException(ErrorCode.SERVER_ERROR,
"Missing required init parameter: " + PATTERN_PARAM);
}
+
try {
- pattern = Pattern.compile(patternParam);
+ pattern = Pattern.compile(patternParam.toString());
} catch (PatternSyntaxException e) {
throw new SolrException(ErrorCode.SERVER_ERROR,
"Invalid regex: " + patternParam, e);
}
- String replacementParam = args.remove(REPLACEMENT_PARAM).toString();
+ Object replacementParam = args.remove(REPLACEMENT_PARAM);
if(replacementParam == null) {
throw new SolrException(ErrorCode.SERVER_ERROR,
"Missing required init parameter: " + REPLACEMENT_PARAM);
}
- replacement = Matcher.quoteReplacement(replacementParam);
+ replacement = Matcher.quoteReplacement(replacementParam.toString());
super.init(args);
}