Skip to content

Add cleanup() to URLFilter and fix timer/client leak in JSONURLFilterWrapper#1867

Merged
jnioche merged 2 commits intomainfrom
fix-json-url-filter-wrapper-leak
Apr 2, 2026
Merged

Add cleanup() to URLFilter and fix timer/client leak in JSONURLFilterWrapper#1867
jnioche merged 2 commits intomainfrom
fix-json-url-filter-wrapper-leak

Conversation

@jnioche
Copy link
Copy Markdown
Contributor

@jnioche jnioche commented Apr 2, 2026

Summary

  • Add cleanup() lifecycle method to URLFilter, mirroring the existing ParseFilter.cleanup() pattern
  • Wire cleanup through URLFilters, StatusEmitterBolt, URLFilterBolt, and all bolt subclasses via super.cleanup() calls
  • Fix JSONURLFilterWrapper: the Timer and RestHighLevelClient were created inside an anonymous TimerTask with no way to cancel or close them — the timer thread runs forever and the client's connection pool is never shut down
  • Store both as instance fields and override cleanup() to cancel the timer and close the client

Changes

  • URLFilter: add cleanup() no-op method (matches ParseFilter)
  • URLFilters: override cleanup() to iterate and call it on each filter
  • StatusEmitterBolt: add cleanup() that calls urlFilters.cleanup()
  • URLFilterBolt: add cleanup() that calls urlFilters.cleanup()
  • 5 bolt subclasses: add super.cleanup() call so URLFilters cleanup is reached
  • JSONURLFilterWrapper: store timer/client as fields, override cleanup()

Test plan

  • Verify compilation with mvn compile -pl external/opensearch -am
  • All core unit tests pass (mvn test -pl core)

🤖 Generated with Claude Code

Add cleanup() lifecycle method to URLFilter (mirroring ParseFilter.cleanup())
and wire it through URLFilters, StatusEmitterBolt, URLFilterBolt, and all
bolt subclasses via super.cleanup() calls.

The Timer and RestHighLevelClient in JSONURLFilterWrapper were created inside
an anonymous TimerTask with no way to cancel or close them. The timer thread
runs forever and the client's connection pool is never shut down.

Store both as instance fields and override cleanup() to cancel the timer and
close the client.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rzo1
Copy link
Copy Markdown
Contributor

rzo1 commented Apr 2, 2026

Needs checkstyle

@jnioche jnioche added this to the 3.5.2 milestone Apr 2, 2026
Signed-off-by: Julien Nioche <julien@digitalpebble.com>
@jnioche jnioche merged commit cdac7e4 into main Apr 2, 2026
2 checks passed
@jnioche jnioche deleted the fix-json-url-filter-wrapper-leak branch April 2, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants