Open
Description
Describe the bug
The user VisibilityFilter
class will typically NPE if deepCopy
is called and then accept
is called on the copy.
Versions (OS, Maven, Java, and others, as appropriate):
- Affected version(s) of this project: All
- OS: N/A
- Others: N/A
To Reproduce
The following unit test proves the problem
public void testDeepCopyAfterInit() throws IOException {
IteratorSetting is = new IteratorSetting(1, VisibilityFilter.class);
VisibilityFilter.setAuthorizations(is, new Authorizations("abc"));
Map<String,String> opts = is.getOptions();
Filter filter = new VisibilityFilter();
TreeMap<Key,Value> source = new TreeMap<>();
filter.init(new SortedMapIterator(source), opts, null);
Filter copyFilter = (Filter) filter.deepCopy(null);
Key k = new Key("row", "cf", "cq", "abc");
assertTrue(copyFilter.accept(k, new Value()));
}
Running this test on 1.X/2.X/3.X will result in an NPE because deepCopy
is not implemented for the VisibilityFilter
.
Expected behavior
copyFilter.accept(k, new Value());
should return true
, not throw an NPE.
Additional context
I'll submit a PR momentarily to demonstrate a possible fix.