logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1586429 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
Date Thu, 10 Apr 2014 19:09:37 GMT
Author: mattsicker
Date: Thu Apr 10 19:09:37 2014
New Revision: 1586429

URL: http://svn.apache.org/r1586429
Log:
Extract method.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java?rev=1586429&r1=1586428&r2=1586429&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
Thu Apr 10 19:09:37 2014
@@ -827,27 +827,7 @@ public abstract class AbstractConfigurat
             sb.append(')');
         }
 
-        if (!attrs.isEmpty()) {
-            final StringBuilder eb = new StringBuilder();
-            for (final String key : attrs.keySet()) {
-                if (eb.length() == 0) {
-                    eb.append(node.getName());
-                    eb.append(" contains ");
-                    if (attrs.size() == 1) {
-                        eb.append("an invalid element or attribute ");
-                    } else {
-                        eb.append("invalid attributes ");
-                    }
-                } else {
-                    eb.append(", ");
-                }
-                eb.append('"');
-                eb.append(key);
-                eb.append('"');
-
-            }
-            LOGGER.error(eb.toString());
-        }
+        checkForRemainingAttributes(node);
 
         if (!type.isDeferChildren() && used.size() != children.size()) {
             for (final Node child : children) {
@@ -901,6 +881,31 @@ public abstract class AbstractConfigurat
         return null;
     }
 
+    private static void checkForRemainingAttributes(final Node node) {
+        final Map<String, String> attrs = node.getAttributes();
+        if (!attrs.isEmpty()) {
+            final StringBuilder eb = new StringBuilder();
+            for (final String key : attrs.keySet()) {
+                if (eb.length() == 0) {
+                    eb.append(node.getName());
+                    eb.append(" contains ");
+                    if (attrs.size() == 1) {
+                        eb.append("an invalid element or attribute ");
+                    } else {
+                        eb.append("invalid attributes ");
+                    }
+                } else {
+                    eb.append(", ");
+                }
+                eb.append('"');
+                eb.append(key);
+                eb.append('"');
+
+            }
+            LOGGER.error(eb.toString());
+        }
+    }
+
     private static String[] extractPluginAliases(final Annotation... parmTypes) {
         String[] aliases = null;
         for (final Annotation a : parmTypes) {



Mime
View raw message