ramanathan1504 commented on code in PR #4153:
URL: https://github.com/apache/logging-log4j2/pull/4153#discussion_r3810785131


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/filter/StringMatchFilter.java:
##########
@@ -230,28 +239,43 @@ public String toString() {
     }
 
     @PluginFactory
-    public static StringMatchFilter.Builder newBuilder() {
-        return new StringMatchFilter.Builder();
+    public static Builder newBuilder() {
+        return new Builder();
     }
 
-    public static class Builder extends 
AbstractFilterBuilder<StringMatchFilter.Builder>
-            implements 
org.apache.logging.log4j.core.util.Builder<StringMatchFilter> {
+    public static class Builder extends AbstractFilterBuilder<Builder>
+            implements 
org.apache.logging.log4j.plugins.util.Builder<StringMatchFilter> {
+
         @PluginBuilderAttribute
-        private String text = "";
+        @Required(message = "No text provided for StringMatchFilter")
+        private String text;
 
         /**
          * Sets the text to search in event messages.
          * @param text the text to search in event messages.
          * @return this instance.
          */
-        public StringMatchFilter.Builder setMatchString(final String text) {
-            this.text = text;
+        public Builder setText(@NonNull final String text) {

Review Comment:
   `getText()` and `setText(String)` are new public API here, but neither 
carries an `@since 3.0.0`, and the `@deprecated` tag at `:265` drops the 
version too. 2.x has `@deprecated since 2.25.0, use setText instead`. Could 
those be added?
   



##########
log4j-core-test/src/test/resources/log4j2-stringmatchfilter-3153-nok.xml:
##########
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<Configuration status="warn">
+   <StringMatchFilter/> <!-- no 'text' attribute: the @Required constraint 
must skip this plugin -->

Review Comment:
   the comment says the `@Required` constraint is what skips the plugin, but if 
I delete the `@Required` line all 6 tests still pass, because the `build()` 
null check catches the config case as well. Could the comment be reworded, or 
the test tied to the actual constraint?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to