Skip to content

Commit

Permalink
Add missing setter in builder classes (apache#3174)
Browse files Browse the repository at this point in the history
This adds setters to `@PluginBuilderAttribute` fields in setter classes that lack the corresponding public setter.
  • Loading branch information
ppkarwasz authored Nov 17, 2024
1 parent 20035c4 commit 8218423
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private Filter createFilter(final String text, final boolean acceptOnMatch) {
? org.apache.logging.log4j.core.Filter.Result.ACCEPT
: org.apache.logging.log4j.core.Filter.Result.DENY;
return FilterWrapper.adapt(StringMatchFilter.newBuilder()
.setMatchString(text)
.setText(text)
.setOnMatch(onMatch)
.setOnMismatch(org.apache.logging.log4j.core.Filter.Result.NEUTRAL)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testFilterBuilderFailsWithNullText() {
@Test
void testFilterBuilderFailsWithExceptionOnNullText() {
Assertions.assertThrows(IllegalArgumentException.class, () -> StringMatchFilter.newBuilder()
.setMatchString(null));
.setText(null));
}

/**
Expand All @@ -56,7 +56,7 @@ void testFilterBuilderFailsWithExceptionOnNullText() {
@Test
void testFilterBuilderFailsWithExceptionOnEmptyText() {
Assertions.assertThrows(IllegalArgumentException.class, () -> StringMatchFilter.newBuilder()
.setMatchString(""));
.setText(""));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,23 @@ public static class Builder extends AbstractFilterBuilder<StringMatchFilter.Buil
@Required(message = "No text provided for StringMatchFilter")
private String text;

/**
* @deprecated since 2.25.0, use {@link #setText} instead.
*/
@Deprecated
public StringMatchFilter.Builder setMatchString(final String text) {
this.text = Assert.requireNonEmpty(text, "The 'text' argument must not be null or empty.");
return this;
}

/**
* Sets the text to search in event messages.
*
* @param text the text to search in event messages.
* @return this instance.
* @since 2.25.0
*/
public StringMatchFilter.Builder setMatchString(final String text) {
public StringMatchFilter.Builder setText(final String text) {
this.text = Assert.requireNonEmpty(text, "The 'text' argument must not be null or empty.");
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* {@link org.apache.logging.log4j.core.Filter#ELEMENT_TYPE filter}.
*/
@Export
@Version("2.21.1")
@Version("2.25.0")
package org.apache.logging.log4j.core.filter;

import org.osgi.annotation.bundle.Export;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,30 @@ public B setMapPrefix(final String prefix) {
}
return asBuilder();
}

/**
* @since 2.25.0
*/
public B setThreadContextIncludes(String threadContextIncludes) {
this.threadContextIncludes = threadContextIncludes;
return asBuilder();
}

/**
* @since 2.25.0
*/
public B setThreadContextExcludes(String threadContextExcludes) {
this.threadContextExcludes = threadContextExcludes;
return asBuilder();
}

/**
* @since 2.25.0
*/
public B setOmitEmptyFields(boolean omitEmptyFields) {
this.omitEmptyFields = omitEmptyFields;
return asBuilder();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,14 @@ public Rfc5424LayoutBuilder setLoggerFields(final LoggerFields[] loggerFields) {
return this;
}

/**
* @since 2.25.0
*/
public Rfc5424LayoutBuilder setEnterpriseNumber(Integer enterpriseNumber) {
this.enterpriseNumber = enterpriseNumber;
return this;
}

@Override
public Rfc5424Layout build() {
if (includes != null && excludes != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* {@link org.apache.logging.log4j.core.Layout#ELEMENT_TYPE layout}.
*/
@Export
@Version("2.24.0")
@Version("2.25.0")
package org.apache.logging.log4j.core.layout;

import org.osgi.annotation.bundle.Export;
Expand Down

0 comments on commit 8218423

Please sign in to comment.