HBASE-6431 Some FilterList Constructors break addFilter (Alex Newman)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1366198 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-07-26 20:53:17 +00:00
parent a5bd687531
commit b358b89351
2 changed files with 29 additions and 4 deletions

View File

@ -74,7 +74,11 @@ public class FilterList implements Filter {
* @param rowFilters list of filters * @param rowFilters list of filters
*/ */
public FilterList(final List<Filter> rowFilters) { public FilterList(final List<Filter> rowFilters) {
this.filters = rowFilters; if (rowFilters instanceof ArrayList) {
this.filters = rowFilters;
} else {
this.filters = new ArrayList<Filter>(rowFilters);
}
} }
/** /**
@ -83,7 +87,7 @@ public class FilterList implements Filter {
* @param rowFilters * @param rowFilters
*/ */
public FilterList(final Filter... rowFilters) { public FilterList(final Filter... rowFilters) {
this.filters = Arrays.asList(rowFilters); this.filters = new ArrayList<Filter>(Arrays.asList(rowFilters));
} }
/** /**
@ -102,7 +106,7 @@ public class FilterList implements Filter {
* @param rowFilters Set of row filters. * @param rowFilters Set of row filters.
*/ */
public FilterList(final Operator operator, final List<Filter> rowFilters) { public FilterList(final Operator operator, final List<Filter> rowFilters) {
this.filters = rowFilters; this.filters = new ArrayList<Filter>(rowFilters);
this.operator = operator; this.operator = operator;
} }
@ -113,7 +117,7 @@ public class FilterList implements Filter {
* @param rowFilters Filters to use * @param rowFilters Filters to use
*/ */
public FilterList(final Operator operator, final Filter... rowFilters) { public FilterList(final Operator operator, final Filter... rowFilters) {
this.filters = Arrays.asList(rowFilters); this.filters = new ArrayList<Filter>(Arrays.asList(rowFilters));
this.operator = operator; this.operator = operator;
} }

View File

@ -54,6 +54,27 @@ public class TestFilterList {
static byte[] GOOD_BYTES = Bytes.toBytes("abc"); static byte[] GOOD_BYTES = Bytes.toBytes("abc");
static byte[] BAD_BYTES = Bytes.toBytes("def"); 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" * Test "must pass one"
* @throws Exception * @throws Exception