Skip to content

DefaultPropertyComponentBuilder generates invalid "Property" Component #3478

Open
@JWT007

Description

@JWT007

Log4j 2.24.3
.----
The DefaultPropertyComponentBuilder does not generate a valid Property Component.

A Log4j XML configuration property should look like this:

<Property name="p1" value="foobar"/>

However, if the ConfigurationBuilder.newProperty("p1", "foobar") is called, it generates a ComponentBuilder equivalent to this.

<Property name="p1">foobar</Property>

This is because in the PropertyComponentBuilder constructor here:

public DefaultPropertyComponentBuilder(final DefaultConfigurationBuilder<? extends Configuration> builder, final String name, final String value) {
   super(builder, name, "Property", value);
 }

... the value gets passed to the super method as the element content value and not as the value attribute.


Correct would probably be:

public DefaultPropertyComponentBuilder(final DefaultConfigurationBuilder<? extends Configuration> builder, final String name, final String value) {
   super(builder, name, "Property", null);
   if (value != null) {
     this.addAttribute("value", value);
   }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions