Apache Lucene open-source search software
SOLR-2027: FacetField.getValues() now returns empty list instead of null
Christopher John Male038a555aefeb
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 6761975e542..dfc154693c8 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -256,7 +256,10 @@ Other Changes* LUCENE-2883: FunctionQuery, DocValues (and its impls), ValueSource (and itsimpls) and BoostedQuery have been consolidated into the queries module. They- can now be found at o.a.l.queries.function.+ can now be found at o.a.l.queries.function.++* SOLR-2027: FacetField.getValues() now returns an empty list if there are no+ values, instead of null (Chris Male)Documentation----------------------diff --git a/solr/src/solrj/org/apache/solr/client/solrj/response/FacetField.java b/solr/src/solrj/org/apache/solr/client/solrj/response/FacetField.javaindex 6b653487344..f46fd97a8cf 100644--- a/solr/src/solrj/org/apache/solr/client/solrj/response/FacetField.java+++ b/solr/src/solrj/org/apache/solr/client/solrj/response/FacetField.java@@ -19,6 +19,7 @@ package org.apache.solr.client.solrj.response;import java.io.Serializable;import java.util.ArrayList;+import java.util.Collections;import java.util.Date;import java.util.List;@@ -145,7 +146,7 @@ import org.apache.solr.client.solrj.util.ClientUtils;}public List<Count> getValues() {- return _values;+ return _values == null ? Collections.<Count>emptyList() : _values;}public int getValueCount()diff --git a/solr/src/test/org/apache/solr/client/solrj/response/FacetFieldTest.java b/solr/src/test/org/apache/solr/client/solrj/response/FacetFieldTest.javanew file mode 100644index 00000000000..beaab3b2d3d--- /dev/null+++ b/solr/src/test/org/apache/solr/client/solrj/response/FacetFieldTest.java@@ -0,0 +1,33 @@+package org.apache.solr.client.solrj.response;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import org.apache.lucene.util.LuceneTestCase;++public class FacetFieldTest extends LuceneTestCase {++ public void testGetValues() {+ FacetField facetField = new FacetField("field");++ assertNotNull(facetField.getValues());+ assertEquals(0, facetField.getValues().size());++ facetField.add("value", 1);+ assertEquals(1, facetField.getValues().size());+ }+}