You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2012/11/04 17:16:17 UTC

svn commit: r1405579 - /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java

Author: ggregory
Date: Sun Nov  4 16:16:17 2012
New Revision: 1405579

URL: http://svn.apache.org/viewvc?rev=1405579&view=rev
Log:
Refactor Result creation with safe upper case in a new toResult method with a default value. This removes a lot of duplicate code.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java?rev=1405579&r1=1405578&r2=1405579&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java Sun Nov  4 16:16:17 2012
@@ -224,20 +224,14 @@ public final class BurstFilter extends A
                                            @PluginAttr("maxBurst") String maxBurst,
                                            @PluginAttr("onmatch") String match,
                                            @PluginAttr("onmismatch") String mismatch) {
-        Result onMatch = Result.toResult(match);
-        Result onMismatch = Result.toResult(mismatch);
+        Result onMatch = Result.toResult(match, Result.NEUTRAL);
+        Result onMismatch = Result.toResult(mismatch, Result.DENY);
         Level lvl = Level.toLevel(level, Level.WARN);
         float eventRate = rate == null ? DEFAULT_RATE : Float.parseFloat(rate);
         if (eventRate <= 0) {
             eventRate = DEFAULT_RATE;
         }
         long max = maxBurst == null ? (long) (eventRate * DEFAULT_RATE_MULTIPLE) : Long.parseLong(maxBurst);
-        if (onMatch == null) {
-            onMatch = Result.NEUTRAL;
-        }
-        if (onMismatch == null) {
-            onMismatch = Result.DENY;
-        }
         return new BurstFilter(lvl, eventRate, max, onMatch, onMismatch);
     }
 }