diff --git a/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java index 68f0c19ef87..2be6b474694 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java +++ b/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java @@ -160,8 +160,8 @@ public abstract class FieldMutatingUpdateProcessorFactory // resolve this into actual Class objects later params.typeClass = args.removeConfigArgs("typeClass"); - // getBooleanArg() returns null if the arg is not specified - params.fieldNameMatchesSchemaField = getBooleanArg(args, "fieldNameMatchesSchemaField"); + // Returns null if the arg is not specified + params.fieldNameMatchesSchemaField = args.removeBooleanArg("fieldNameMatchesSchemaField"); return params; } @@ -247,7 +247,10 @@ public abstract class FieldMutatingUpdateProcessorFactory * Removes the first instance of the key from NamedList, returning the Boolean * that key referred to, or null if the key is not specified. * @exception SolrException invalid type or structure + * @deprecated Use {@link NamedList#removeBooleanArg} instead. Will be + * removed in 5.0. */ + @Deprecated public static Boolean getBooleanArg(final NamedList args, final String key) { Boolean bool; List values = args.getAll(key); diff --git a/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java b/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java index 1322127de88..63309c4bef6 100644 --- a/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java +++ b/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java @@ -494,7 +494,8 @@ public class NamedList implements Cloneable, Serializable, Iterable implements Cloneable, Serializable, Iterable values = getAll(name); + if (0 == values.size()) { + return null; + } + if (values.size() > 1) { + throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, + "Only one '" + name + "' is allowed"); + } + Object o = get(name); + if (o instanceof Boolean) { + bool = (Boolean)o; + } else if (o instanceof CharSequence) { + bool = Boolean.parseBoolean(o.toString()); + } else { + throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, + "'" + name + "' must have type 'bool' or 'str'; found " + o.getClass()); + } + remove(name); + return bool; + } + /** * Used for getting one or many arguments from NamedList objects that hold * configuration parameters. Finds all entries in the NamedList that match @@ -520,6 +561,8 @@ public class NamedList implements Cloneable, Serializable, Iterable