apache / apache/logging-log4j2

DefaultPropertyComponentBuilder generates invalid "Property" Component

Open
#3,478 5 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

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

A Log4j XML configuration property should look like this:

``

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

`foobar`

This is because in the `PropertyComponentBuilder `constructor here:

```
public DefaultPropertyComponentBuilder(final DefaultConfigurationBuilder 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 builder, final String name, final String value) {
super(builder, name, "Property", null);
if (value != null) {
this.addAttribute("value", value);
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.