Skip to content

URLFilters: treat an exception from a filter as a rejection - #2120

Open
abhinav-phi wants to merge 1 commit into
apache:mainfrom
abhinav-phi:issue-2084-urlfilters-exception
Open

URLFilters: treat an exception from a filter as a rejection#2120
abhinav-phi wants to merge 1 commit into
apache:mainfrom
abhinav-phi:issue-2084-urlfilters-exception

Conversation

@abhinav-phi

Copy link
Copy Markdown
Contributor

Fixes #2084.

The try/catch wrapped the whole chain: when a filter threw, the catch logged the exception and fell through to the value the last successful filter had produced, so callers such as StatusEmitterBolt.filterOutlink treated the URL as accepted and every filter after the one that threw was skipped — including the regex exclusions the archetype places last.

  • the try/catch now sits inside the loop: it logs which filter threw and returns null, so a broken chain cannot widen what the crawl accepts
  • main() applies the same verdict so the command line tool agrees with the topology
  • a counter (getExceptionsCount()) records how often it happens
  • FastURLFilter.Rule rejects a rule line without a recognised type at load time instead of building a rule with a null type that throws when evaluated

This changes behaviour for topologies that currently have a throwing filter and did not notice: those URLs start being dropped instead of emitted.

)

The try/catch wrapped the whole chain: when a filter threw, the catch
logged and fell through to the value the last successful filter had
produced, so callers saw the URL as accepted and every filter after the
one that threw was skipped - including the regex exclusions placed last
in the archetype chain.

The try/catch now sits inside the loop, logs which filter threw and
returns null: a chain which throws must not widen what the crawl
accepts. main() applies the same verdict, and a counter records how
often it happens.

FastURLFilter.Rule no longer accepts a rule line without a recognised
type; it failed at evaluation time with an NPE and now fails at load
time instead.
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.

URLFilters.filter() returns the URL as accepted when a filter in the chain throws

1 participant