You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2024/06/19 16:48:46 UTC

(causeway) branch CAUSEWAY-3781 updated: CAUSEWAY-3781: fixes static factory method

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch CAUSEWAY-3781
in repository https://gitbox.apache.org/repos/asf/causeway.git


The following commit(s) were added to refs/heads/CAUSEWAY-3781 by this push:
     new 4e5f13dc20 CAUSEWAY-3781: fixes static factory method
4e5f13dc20 is described below

commit 4e5f13dc20b5fde11a8304f5557f59ee9f7a699f
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Jun 19 17:48:42 2024 +0100

    CAUSEWAY-3781: fixes static factory method
---
 .../causeway/applib/log4j2/DuplicateMessageFilter.java      | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/causeway/applib/log4j2/DuplicateMessageFilter.java b/api/applib/src/main/java/org/apache/causeway/applib/log4j2/DuplicateMessageFilter.java
index 4970501de3..4b73e68383 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/log4j2/DuplicateMessageFilter.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/log4j2/DuplicateMessageFilter.java
@@ -12,6 +12,7 @@ import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.Node;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
 import org.apache.logging.log4j.core.filter.AbstractFilter;
 import org.apache.logging.log4j.message.Message;
@@ -44,7 +45,6 @@ import org.apache.logging.log4j.message.Message;
  * </pre>
  */
 @Plugin(name = "DuplicateMessageFilter", category = Node.CATEGORY, elementType = Filter.ELEMENT_TYPE, printObject = true)
-@RequiredArgsConstructor
 public class DuplicateMessageFilter extends AbstractFilter {
 
     private static final Logger log = LogManager.getLogger(DuplicateMessageFilter.class);
@@ -52,6 +52,10 @@ public class DuplicateMessageFilter extends AbstractFilter {
     private volatile Message lastMessage = null;
     private final AtomicInteger repeatCount = new AtomicInteger(0);
 
+    public DuplicateMessageFilter(Result onMatch, Result onMismatch) {
+        super(onMatch, onMismatch);
+    }
+
     @Override
     public Result filter(org.apache.logging.log4j.core.Logger logger, Level level, Marker marker, Message msg, Throwable t) {
         return super.filter(logger, level, marker, msg, t);
@@ -87,7 +91,10 @@ public class DuplicateMessageFilter extends AbstractFilter {
     }
 
     @PluginFactory
-    public static DuplicateMessageFilter createFilter() {
-        return new DuplicateMessageFilter();
+    public static DuplicateMessageFilter createFilter(
+            @PluginAttribute(value = "onMatch", defaultString = "NEUTRAL") Result onMatch,
+            @PluginAttribute(value = "onMismatch", defaultString = "DENY") Result onMismatch
+    ) {
+        return new DuplicateMessageFilter(onMatch, onMatch);
     }
 }