Skip to content

Remove the patternFlags attribute from RegexFilter#4119

Merged
vy merged 14 commits into
apache:2.xfrom
ramanathan1504:fix-regex-pattern-flags
Jun 11, 2026
Merged

Remove the patternFlags attribute from RegexFilter#4119
vy merged 14 commits into
apache:2.xfrom
ramanathan1504:fix-regex-pattern-flags

Conversation

@ramanathan1504

Copy link
Copy Markdown
Contributor

Fixes #3086

This pull request refactors the RegexFilter to use a plugin builder pattern, restores support for configuring regex patternFlags via a comma-separated attribute, and improves robustness around the useRawMsg option. It also adds tests and documentation for the new pattern flags feature.

RegexFilter Refactor and Feature Restoration:

  • Refactored RegexFilter to use a plugin builder (Builder class), simplifying construction and improving maintainability. The builder now uses a primitive boolean for useRawMsg to avoid null-unboxing issues. [1] [2]
  • Restored and improved support for configurable regex patternFlags via a comma-separated string attribute (e.g., patternFlags="CASE_INSENSITIVE"), replacing the previous, more cumbersome approach.

Testing Improvements:

  • Added a new test (testPatternFlagsFromConfiguration) in RegexFilterTest.java to verify that pattern flags are correctly loaded from configuration files.
  • Added a corresponding test configuration file RegexFilterPatternFlagsTest.xml to exercise the new pattern flags feature.

Documentation and Changelog:

  • Updated the manual to document the patternFlags attribute, listing all supported flag values and usage.
  • Added a changelog entry describing the refactor, restoration of patternFlags, and the builder improvements.

Other:

  • Bumped the OSGi version for the filter package to 2.26.0 to reflect the new feature.

jethomas-tsi and others added 8 commits March 2, 2025 21:11
+ made AbstractFiltter.AbstractFilterBuilder onMatch/onMismatch fields protected
+ added AbstractFilter(AbstractFilterBuilder) constructor
+ added RegexFilter.Builder implementation
+ added RegexFilter(Builder) constructor
+ moved RegexFilter Pattern compile into constructor
+ added fields to persist configuration propertties + getters (regexExpression, patternFlags)
+ changed private constructor to accept builder as argument
+ renamed private method 'targetMessageTest' to more approprriate 'getMessageTextByType'
+ added Javadoc
+ grouped deprecations
+ added validation checks to RegexFilter
+ added JVerify nullability annotations to RegexFilter
+ updated javadoc
+ replaced deprecated usages of CompositeFilter#getFilters with CompositeFilter#getFiltersArray in AbstractFilterableTest
…gex patternFlags via a CSV attribute, and improve handling of useRawMsg with a primitive boolean.
Comment thread log4j-core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java Outdated
@vy vy changed the title Refactor RegexFilter to use a plugin builder, restore configurable re… Remove the patternFlags attribute from RegexFilter Jun 11, 2026
@vy vy enabled auto-merge (squash) June 11, 2026 15:45
@vy vy merged commit 2ca8348 into apache:2.x Jun 11, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Merged in Log4j pull request tracker Jun 11, 2026
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.

Fix RegexFilter pattern flags

4 participants