Skip to content

HBASE-30033 Scan.setFilter() should validate against existing batch setting#7988

Open
mini666 wants to merge 4 commits intoapache:masterfrom
mini666:HBASE-30033
Open

HBASE-30033 Scan.setFilter() should validate against existing batch setting#7988
mini666 wants to merge 4 commits intoapache:masterfrom
mini666:HBASE-30033

Conversation

@mini666
Copy link
Copy Markdown

@mini666 mini666 commented Mar 27, 2026

Summary

Scan.setBatch() validates that the scan does not have a filter with hasFilterRow()=true, throwing IncompatibleFilterException if it does. However, Scan.setFilter() does not perform the reverse check against an existing batch setting.

This allows creating an invalid Scan by calling setBatch() before setFilter(), bypassing the validation:

// This correctly throws IncompatibleFilterException
Scan scan = new Scan();
scan.setFilter(new PageFilter(10));
scan.setBatch(5); // throws

// This silently creates the same invalid combination
Scan scan = new Scan();
scan.setBatch(5);
scan.setFilter(new PageFilter(10)); // no validation

Fix

Added validation in Scan.setFilter() to throw IncompatibleFilterException when a filter with hasFilterRow()=true is set on a scan that already has batch configured.

Jira

https://issues.apache.org/jira/browse/HBASE-30033

@liuxiaocs7
Copy link
Copy Markdown
Member

Hi, @mini666, please rebase master and retry?

Thanks!

mini666 added 2 commits March 27, 2026 13:29
…etting

Scan.setBatch() validates that the scan does not have a filter with
hasFilterRow()=true. However, Scan.setFilter() does not perform the
reverse check. This allows creating an invalid Scan by calling
setBatch() before setFilter(), bypassing the validation that
setBatch() was designed to enforce.

Added validation in setFilter() to throw IncompatibleFilterException
when a filter with hasFilterRow()=true is set on a scan that already
has batch configured.
- testSetFilterWithBatchThrows: setBatch() then setFilter(PageFilter)
  should throw IncompatibleFilterException
- testSetFilterWithoutBatchDoesNotThrow: setFilter(PageFilter) without
  batch should succeed
- testSetFilterWithBatchAndNonFilterRowFilter: setBatch() then
  setFilter(FilterList) should succeed since FilterList.hasFilterRow()
  returns false
Copy link
Copy Markdown
Contributor

@vaijosh vaijosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Apache9
Copy link
Copy Markdown
Contributor

Apache9 commented Mar 27, 2026

We have already migrated to junit5 so we can not use expected any more. Please use assertThrows instead.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants