-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: 2.x
Are you sure you want to change the base?
Conversation
…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.
There was a problem hiding this 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!
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ScriptsPlugin.java
Outdated
Show resolved
Hide resolved
log4j-core/src/main/java/org/apache/logging/log4j/core/script/AbstractScript.java
Outdated
Show resolved
Hide resolved
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ScriptsPluginTest.java
Outdated
Show resolved
Hide resolved
log4j-core-test/src/test/java/org/apache/logging/log4j/core/script/AbstractScriptTest.java
Outdated
Show resolved
Hide resolved
log4j-core-test/src/test/java/org/apache/logging/log4j/core/script/AbstractScriptTest.java
Outdated
Show resolved
Hide resolved
log4j-core/src/main/java/org/apache/logging/log4j/core/script/package-info.java
Outdated
Show resolved
Hide resolved
- 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.
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. |
I'll merge this PR as soon as BTW: thanks for contributing to my coffee fund! |
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 providesgetName()
strictly for user-configured names, which can be null or blank. It also introducesgetId()
to consistently return a non-blank internal identifier, falling back totoString()
if no explicit name is set.ScriptsPlugin
now throws aConfigurationException
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 thescript.getId()
for internal referencing.AbstractScript
andScriptsPlugin
.