2791 Fix handling of onMatch and onMismatch attributes in the properties configuration format#3505
2791 Fix handling of onMatch and onMismatch attributes in the properties configuration format#3505JWT007 wants to merge 8 commits into
onMatch and onMismatch attributes in the properties configuration format#3505Conversation
…Attributte (apache#2791) + more appropriate method name
+ made all Default***Builder implementations @ProviderrType + added setXXXAttribute method to some component builder interfaces with default implementations + added JSpecify @NullMarked to packages and @nullable where approrpiate to fields/mehods (per last PR review) + deprecated ComponentBuilder#addAttribute(...) methods and replaced with ComponentBuilder#setAttribute(...) methods in line with other builders (i.e. Plugins) - also since they don't just add but also remove if the value is null + reorganized ConfigurationBuilder to group getters, setters, builder factory methods + incremented package-info.java @Version annoations + added some null-guards in BuiltConfiguration#setup() + moved DeffaultConfigurationBuilder XML generation code from top to bottom of source file + removed "extra" attributes in Default***Builder constructors and replaced with setXXXAttribute chained calls in DefaultConfigurrationBuilder#newXXX(...) convenience methods + javadoc'd both packages (fixing documentation errors)
…instead of void (apache#2791) + added @BaselineIgnore due to API change (but breaks no code)
ppkarwasz
left a comment
There was a problem hiding this comment.
Thanks for the PR! 💯
Overall it looks OK, I added some notes below:
| try (final LoggerContext loggerContext1 = | ||
| try (final LoggerContext tLoggerContext1 = |
There was a problem hiding this comment.
This isn't really necessary (and the 3 changes below).
| * @throws NullPointerException if the given {@code key} is {@code null} | ||
| */ | ||
| T addAttribute(String key, Level level); | ||
| T setAttribute(String key, @Nullable Level level); |
There was a problem hiding this comment.
We can probably provide a default implementation for these methods.
| * @param level the level | ||
| * @return this builder (for chaining) | ||
| */ | ||
| default AppenderRefComponentBuilder setLevelAttribute(@Nullable String level) { |
There was a problem hiding this comment.
IMHO setLevel would be a better naming choice: it is not ambiguous and it is shorter.
Should we remove the Attribute suffix from all new methods?
| * of the Assembler API. | ||
| * @since 2.4 | ||
| */ | ||
| @ProviderType |
There was a problem hiding this comment.
| @ProviderType |
This class is not meant to be extended by neither consumers nor providers, so no annotation is needed.
| * @param newValue the new value | ||
| * @return the previous value or {@code null} if none was set | ||
| */ | ||
| protected @Nullable String putAttribute(final String key, final @Nullable String newValue) { |
There was a problem hiding this comment.
Why is this protected?
It has a better sounding name than addAttribute. Maybe addAttribute should be deprecated (possibly with an Error Prone @InlineMe annotation) and this should be public?
| @Override | ||
| public T addAttribute(final String key, final int value) { | ||
| return put(key, Integer.toString(value)); | ||
| public @NonNull CB getBuilder() { |
There was a problem hiding this comment.
| public @NonNull CB getBuilder() { | |
| public CB getBuilder() { |
Isn't @NonNull the default?
| synchronized (this) { | ||
| attributes.clear(); | ||
| components.clear(); | ||
| } |
There was a problem hiding this comment.
Since the class is not thread-safe anyway, do we need this?
| * Gets the list of child components. | ||
| * @return an <i>immutable</i> list of the child components | ||
| */ | ||
| protected List<Component> getComponents() { |
There was a problem hiding this comment.
| protected List<Component> getComponents() { | |
| protected List<? extends Component> getComponents() { |
| final String name = (String) properties.remove(CONFIG_NAME); | ||
| final String type = (String) properties.remove(CONFIG_TYPE); | ||
| if (Strings.isEmpty(type)) { | ||
| if (type == null || Strings.isEmpty(type)) { |
There was a problem hiding this comment.
| if (type == null || Strings.isEmpty(type)) { | |
| if (Strings.isEmpty(type)) { |
Strings.isEmpty is null-safe.
| <issue id="2791" link="https://github.com/apache/logging-log4j2/issues/2791"/> | ||
| <description format="asciidoc"> | ||
| Fix problem when null attribute values are set on DefaultComponentBuilder. GitHub issue #2791. | ||
| Added JVerify annotations to config.builder.* packages. |
There was a problem hiding this comment.
| Added JVerify annotations to config.builder.* packages. | |
| Added JSpecify annotations to config.builder.* packages. |
|
@ramanathan1504, is this something you might want to pick up? |
|
@vy, Yes, I can pick this up. I will review this PR and the issue discussion and come up with updated one. |
|
Superseded by #4116. |
#2791
put(String, String)to remove attributte if value is nullputAttribute(...)implementations with object values against NPE(edit)
config.builderandconfig.builder.apipackages