Skip to content

[main] Fix RegexFilter NPE when useRawMsg is null (#3265 port)#4152

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

[main] Fix RegexFilter NPE when useRawMsg is null (#3265 port)#4152
vpelikh wants to merge 1 commit into
apache:mainfrom
vpelikh:GH-3265-port-to-main

Conversation

@vpelikh

@vpelikh vpelikh commented Jun 26, 2026

Copy link
Copy Markdown

Ports the fix from #3265 from the 2.x branch to main.

In the RegexFilter.createFilter() factory method, the useRawMsg parameter is declared as Boolean (boxed). When passed directly to the RegexFilter(boolean raw, ...) constructor, a null value causes an NPE during unboxing.

This change uses Boolean.TRUE.equals(useRawMsg) instead, which safely handles null by defaulting to false.

Changes

  • log4j-core/.../filter/RegexFilter.java: Changed useRawMsgBoolean.TRUE.equals(useRawMsg) in constructor call
  • log4j-core-test/.../filter/RegexFilterTest.java: Added test ensuring no exception when useRawMsg is null

Avoid NPE when unboxing a null Boolean by using Boolean.TRUE.equals().

Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
@vpelikh vpelikh force-pushed the GH-3265-port-to-main branch from f0af2d0 to 666c239 Compare June 26, 2026 07:25
@vpelikh vpelikh changed the title [main] Fix RegexFilter NPE when useRawMsg is null (#3265) [main] Fix RegexFilter NPE when useRawMsg is null (#3265 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