diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java index 8e9c1c86851..e5e359796d7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java @@ -74,7 +74,11 @@ public class FilterList implements Filter { * @param rowFilters list of filters */ public FilterList(final List rowFilters) { - this.filters = rowFilters; + if (rowFilters instanceof ArrayList) { + this.filters = rowFilters; + } else { + this.filters = new ArrayList(rowFilters); + } } /** @@ -83,7 +87,7 @@ public class FilterList implements Filter { * @param rowFilters */ public FilterList(final Filter... rowFilters) { - this.filters = Arrays.asList(rowFilters); + this.filters = new ArrayList(Arrays.asList(rowFilters)); } /** @@ -102,7 +106,7 @@ public class FilterList implements Filter { * @param rowFilters Set of row filters. */ public FilterList(final Operator operator, final List rowFilters) { - this.filters = rowFilters; + this.filters = new ArrayList(rowFilters); this.operator = operator; } @@ -113,7 +117,7 @@ public class FilterList implements Filter { * @param rowFilters Filters to use */ public FilterList(final Operator operator, final Filter... rowFilters) { - this.filters = Arrays.asList(rowFilters); + this.filters = new ArrayList(Arrays.asList(rowFilters)); this.operator = operator; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java index 85948cb4486..196c0ca36dc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java @@ -54,6 +54,27 @@ public class TestFilterList { static byte[] GOOD_BYTES = Bytes.toBytes("abc"); static byte[] BAD_BYTES = Bytes.toBytes("def"); + + @Test + public void testAddFilter() throws Exception { + Filter filter1 = new RowFilter(); + Filter filter2 = new RowFilter(); + + FilterList filterList = new FilterList(filter1, filter2); + filterList.addFilter(new RowFilter()); + + filterList = new FilterList(Arrays.asList(filter1, filter2)); + filterList.addFilter(new RowFilter()); + + filterList = new FilterList(Operator.MUST_PASS_ALL, filter1, filter2); + filterList.addFilter(new RowFilter()); + + filterList = new FilterList(Operator.MUST_PASS_ALL, Arrays.asList(filter1, filter2)); + filterList.addFilter(new RowFilter()); + + } + + /** * Test "must pass one" * @throws Exception