Skip to content

[main] Add @Required and validation to StringMatchFilter text attribute (#3158 port)#4153

Open
vpelikh wants to merge 1 commit into
apache:mainfrom
vpelikh:GH-3158-port-to-main
Open

[main] Add @Required and validation to StringMatchFilter text attribute (#3158 port)#4153
vpelikh wants to merge 1 commit into
apache:mainfrom
vpelikh:GH-3158-port-to-main

Conversation

@vpelikh

@vpelikh vpelikh commented Jun 26, 2026

Copy link
Copy Markdown

Ports #3158 from the 2.x branch to 3.x.

Changes

  • StringMatchFilter.java: Added @Required constraint annotation on the text builder field, Assert.requireNonEmpty checks in the constructor and setMatchString() method, and a null/empty validation guard in build() returning the null filter sentinel when validation fails
  • StringMatchFilterTest.java: Added 5 test methods covering valid construction, empty text rejection, null text rejection, missing attribute rejection, and post-stop guard
  • Test configs: Added log4j2-stringmatchfilter-3153-ok.xml and log4j2-stringmatchfilter-3153-nok.xml fixture configurations

Why

An empty or missing text attribute on StringMatchFilter previously resulted in either a cryptic NullPointerException at runtime (after stop()) or silently matching the empty string against every event. This change provides clear validation at configuration time and graceful degradation.

@vpelikh vpelikh force-pushed the GH-3158-port-to-main branch 3 times, most recently from 089cd4e to 340a851 Compare June 26, 2026 08:12
apache#3158)

Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
@vpelikh vpelikh force-pushed the GH-3158-port-to-main branch from 340a851 to fd62c22 Compare June 26, 2026 08:20
@vpelikh vpelikh changed the title [main] Add @Required and validation to StringMatchFilter text attribute (#3158) [main] Add @Required and validation to StringMatchFilter text attribute (#3158 port) Jun 26, 2026
@vpelikh vpelikh mentioned this pull request Jun 26, 2026
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant