You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Matt Sicker (Jira)" <ji...@apache.org> on 2019/09/15 19:04:00 UTC

[jira] [Commented] (LOG4J2-2693) @PluginValue does not support attribute names besides "value"

    [ https://issues.apache.org/jira/browse/LOG4J2-2693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16930051#comment-16930051 ] 

Matt Sicker commented on LOG4J2-2693:
-------------------------------------

I bring this up because this seems strange to have the {{value}} attribute on {{@PluginValue}} if it's not used for anything. In XML, you can specify a value using {{<Foo>baz</Foo>}}, but this only works in XML. For JSON, YAML, and properties files, you'd have to specify a pseudo {{value}} attribute. If I specify a different attribute name than "value" in the annotation, should that make that a pseudo-attribute for {{value}}?

There are only two uses of {{@PluginValue}} in log4j-core:

* In {{Properties}} where it uses the value {{value}}
* In {{Script}} where it uses the value {{scriptText}}

I can't find any tests that use {{scriptText}} in a config file, so there are no examples of expected behavior other than my own question here. I'll note that this behavior dates back at least as far as the initial injection visitor refactoring a few years ago, and from what I recall, that refactoring ported existing behavior (which has since been [changed a few times|https://github.com/apache/logging-log4j2/blame/master/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/inject/PluginValueBuilder.java#L36]), so it's hard to determine what the original expectation was.

> @PluginValue does not support attribute names besides "value"
> -------------------------------------------------------------
>
>                 Key: LOG4J2-2693
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2693
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Plugins
>    Affects Versions: 2.12.1
>            Reporter: Matt Sicker
>            Priority: Major
>
> While working in the plugin system recently, I discovered an inconsistent behavior in how {{@PluginValue}} works compared to {{@PluginAttribute}}. If a {{value}} is specified other than "value", then I'd expect that the contents of that value to be the attribute name in the configuration file.
> For example:
> {code:java}
> @Plugin(name = "Foo", category = "Core", ...)
> public class Foo {
> // ...
> @PluginFactory
> public static Foo createFoo(@PluginValue("bar") String bar) {
>   return new Foo(bar);
> }
> }
> {code}
> Expected XML config:
> {code:xml}
> <Foo bar="baz"/>
> {code}
> Actual XML config:
> {code:xml}
> <Foo value="baz"/>
> {code}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)