Skip to content

Enforce explicit names for global scripts and refine script id handling #3691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

jhl221123
Copy link
Contributor

This PR addresses issue #3176 by ensuring scripts defined in the global <Scripts> container have explicit, non-blank names. It also introduces a clearer distinction between user-defined names and internal script identifiers.

Key Changes:

  • AbstractScript now provides getName() strictly for user-configured names, which can be null or blank. It also introduces getId() to consistently return a non-blank internal identifier, falling back to toString() if no explicit name is set.
  • ScriptsPlugin now throws a ConfigurationException if any script defined directly under the global <Scripts> element lacks an explicit name.
  • ScriptManager and various script-using components were updated. They now utilize the script.getId() for internal referencing.
  • Added unit tests for AbstractScript and ScriptsPlugin.

…cripts container

This commit introduces a clearer distinction between user-defined script names and internal script identifiers, and enforces explicit naming for global scripts.
- AbstractScript now provides 'getName()' for user-set names and 'getId()' for an internal Id.
- ScriptsPlugin throws a 'ConfigurationException' if global scripts lack a non-blank name via 'getName()'.
- ScriptManager and its users were updated to utilize 'script.getId()' for internal referencing.
- Added unit tests for 'AbstractScript' and 'ScriptsPlugin'.
- Updated 'org.apache.logging.log4j.core.script' package-info to version 2.25.0.
- Added a changelog entry for issue apache#3176.
Copy link

github-actions bot commented May 26, 2025

Job Requested goals Build Tool Version Build Outcome Build Scan®
build-macos-latest clean install 3.9.8 Build Scan PUBLISHED
build-ubuntu-latest clean install 3.9.8 Build Scan PUBLISHED
build-windows-latest clean install 3.9.8 Build Scan PUBLISHED
Generated by gradle/develocity-actions

Copy link
Contributor

@ppkarwasz ppkarwasz left a comment

Choose a reason for hiding this comment

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

Hi @jhl221123,

Thanks for the PR, and apologies for the delay—we're a bit short on bandwidth at the moment.

You've done a great job here. The PR includes all the necessary elements, and I appreciate that you followed our custom policy for @Version annotations as well. Nicely done!

- Improve null-safety in ScriptsPlugin by throwing an exception for null input.
- Replace unsafe toString() call in AbstractScript constructor with a safer internal ID generation.
- Adjust test cases to align with code changes and project conventions.
- Update OSGi @Version annotation to 2.26.0 for the next release cycle.
@jhl221123
Copy link
Contributor Author

Hi @ppkarwasz,

Thanks for the thorough review!

I've addressed all feedback. It was a great learning experience. Let me know if any further changes are needed.

@ppkarwasz
Copy link
Contributor

@jhl221123,

I'll merge this PR as soon as 2.25.0 is out.

BTW: thanks for contributing to my coffee fund!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To triage
Development

Successfully merging this pull request may close these issues.

2 participants