Skip to content

Honor ConfigurationFactory active state - #4199

Open
DragonFSKY wants to merge 3 commits into
apache:2.xfrom
DragonFSKY:fix-3896-configuration-factory-active
Open

Honor ConfigurationFactory active state#4199
DragonFSKY wants to merge 3 commits into
apache:2.xfrom
DragonFSKY:fix-3896-configuration-factory-active

Conversation

@DragonFSKY

@DragonFSKY DragonFSKY commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #3896.

This change makes ConfigurationFactory active-state handling consistent:

  • Factories expose their supported types regardless of active state.
  • Inactive factories return null, and aggregate lookup does not invoke them to create configurations.
  • Default resource discovery preserves the existing file-specific diagnostic for matching inactive factories and continues fallback lookup.
  • JSON and YAML factories honor overridden isActive() implementations, while Log4j 1.x compatibility factories track the compatibility property dynamically.

Tests cover aggregate lookup paths, inactive-factory diagnostics and fallback, dynamic activation, overridden active state, and missing JSON/YAML dependencies. Existing Log4j 1.x configuration tests explicitly enable compatibility mode where required, and the affected OSGi package versions reflect the protected overrides.

Checklist

  • Base your changes on 2.x branch if you are targeting Log4j 2; use main otherwise
  • ./mvnw -pl log4j-core-test,log4j-1.2-api -am verify succeeds (the build instructions)
  • Non-trivial changes contain an entry file in the src/changelog/.2.x.x directory
  • Tests are provided

@ramanathan1504

Copy link
Copy Markdown
Contributor

@DragonFSKY I've just taken a quick look at your PR and noticed there are multiple new test cases. Since it touches multiple files, please give us a little time. We will review it ASAP!

@ramanathan1504 ramanathan1504 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result: with jackson-dataformat-yaml absent, getSupportedTypes() still returns the YAML suffixes, so today a log4j2.yaml match logs that ERROR naming the file and the likely cause. After this change the factory is skipped before that point and nothing is logged. Please log before the continue.

@github-project-automation github-project-automation Bot moved this to Changes requested in Log4j pull request tracker Aug 1, 2026
@DragonFSKY

Copy link
Copy Markdown
Contributor Author

Thanks for catching this! I've fixed it. Please let me know if anything else needs adjusting.

@DragonFSKY
DragonFSKY force-pushed the fix-3896-configuration-factory-active branch 3 times, most recently from d8f4a05 to 7b7c20b Compare August 1, 2026 06:58
@DragonFSKY
DragonFSKY force-pushed the fix-3896-configuration-factory-active branch from 7b7c20b to 6b8ec39 Compare August 3, 2026 02:09
@ramanathan1504

Copy link
Copy Markdown
Contributor

@DragonFSKY don't use force push.it will completely clear the old review..Thanks

@DragonFSKY

Copy link
Copy Markdown
Contributor Author

Thanks for the reminder, and sorry about that. I'll avoid force-pushing and keep any further review updates as separate commits. Since I had already squashed the branch before seeing your note, would you prefer that I leave it as is, or split the current change into two commits for easier review? I understand that this would require one more force-push, so I won't change the history unless you prefer it.

Comment thread src/changelog/.2.x.x/fix_configuration_factory_activation.xml
Comment thread src/changelog/.2.x.x/fix_configuration_factory_activation.xml Outdated
@DragonFSKY

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I’ve moved the active-state checks to the factory loops and applied the suggested diagnostic and changelog updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Changes requested

Development

Successfully merging this pull request may close these issues.

Fix ConfigurationFactory::isActive overrides

3 participants