You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a configuration builder and adding a FilterComponentBuilder, generating XML from the ConfigurationBuilder causes exception when the filter is defined with a null OnMatch/OnMismatch Result.
Configuring the onMatch/onMismatch attributes is not required - null should be a valid value.
In this case, no attributtes should be added.
However in tthe DefaulttFilterComponentBuilder, attributes are added to tthe builder without performing a null-check first.
class DefaultFilterComponentBuilder extends DefaultComponentAndConfigurationBuilder<FilterComponentBuilder>
implements FilterComponentBuilder {
public DefaultFilterComponentBuilder(
final DefaultConfigurationBuilder<? extends Configuration> builder,
final String type,
final String onMatch,
final String onMismatch) {
super(builder, type);
addAttribute(AbstractFilterBuilder.ATTR_ON_MATCH, onMatch);
addAttribute(AbstractFilterBuilder.ATTR_ON_MISMATCH, onMismatch);
}
}
This results attributes with null values in the builder tree which can cause XML serialization problems.
I think this might be better:
class DefaultFilterComponentBuilder extends DefaultComponentAndConfigurationBuilder<FilterComponentBuilder>
implements FilterComponentBuilder {
public DefaultFilterComponentBuilder(
final DefaultConfigurationBuilder<? extends Configuration> builder,
final String type,
final String onMatch,
final String onMismatch) {
super(builder, type);
Optional.ofNullable(onMatch).ifPresent(() -> addAttribute(AbstractFilterBuilder.ATTR_ON_MATCH, onMatch));
Optional.ofNullable(onMismatch).ifPresent(() -> addAttribute(AbstractFilterBuilder.ATTR_ON_MISMATCH, onMismatch));
}
}
The text was updated successfully, but these errors were encountered:
Log4j 2.24.3
When using a configuration builder and adding a FilterComponentBuilder, generating XML from the ConfigurationBuilder causes exception when the filter is defined with a null OnMatch/OnMismatch Result.
Configuring the onMatch/onMismatch attributes is not required - null should be a valid value.
In this case, no attributtes should be added.
However in tthe DefaulttFilterComponentBuilder, attributes are added to tthe builder without performing a null-check first.
This results attributes with null values in the builder tree which can cause XML serialization problems.
I think this might be better:
The text was updated successfully, but these errors were encountered: