[logback-dev] svn commit: r1768 - logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi

noreply.ceki at qos.ch noreply.ceki at qos.ch
Wed Aug 20 17:45:39 CEST 2008


Author: ceki
Date: Wed Aug 20 17:45:39 2008
New Revision: 1768

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java

Log:

really skip over children when an error occurs. In the previous version of the code, 
we would skip over invoking the action but would still try to find actions for the event. 
In this revision, we skip over the event as a whole, in particular we no longer look up
actions for it. In practical terms, this just avoids adding error statuses for not found 
implicit actions. 


Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java	Wed Aug 20 17:45:39 2008
@@ -114,24 +114,33 @@
       String qName, Attributes atts) {
 
     String tagName = getTagName(localName, qName);
-
-    // System.out.println("startElement [" + tagName + "]");
-
     pattern.push(tagName);
 
-    List applicableActionList = getApplicableActionList(pattern, atts);
+    if (skip != null) {
+      // every startElement pushes an action list
+      pushEmptyActionList();
+      return;
+    }
 
+    List applicableActionList = getApplicableActionList(pattern, atts);
     if (applicableActionList != null) {
       actionListStack.add(applicableActionList);
       callBeginAction(applicableActionList, tagName, atts);
     } else {
-      actionListStack.add(EMPTY_LIST);
-
+      // every startElement pushes an action list
+      pushEmptyActionList();
       String errMsg = "no applicable action for [" + tagName
           + "], current pattern is [" + pattern + "]";
       cai.addError(errMsg);
     }
   }
+  
+  /**
+   * This method is used to 
+   */
+  private void pushEmptyActionList() {
+    actionListStack.add(EMPTY_LIST);
+  }
 
   public void characters(BodyEvent be) {
 
@@ -155,14 +164,13 @@
   }
 
   private void endElement(String namespaceURI, String localName, String qName) {
+    // given that an action list is always pushed for every startElement, we need
+    // to always pop for every endElement
     List applicableActionList = (List) actionListStack.pop();
-    // System.out.println("endElement ["+getTagName(localName, qName)+"]");
-
+   
     if (skip != null) {
       if (skip.equals(pattern)) {
         skip = null;
-        // FIXME
-        // callEndAction(applicableActionList, getTagName(localName, qName));
       }
     } else if (applicableActionList != EMPTY_LIST) {
       callEndAction(applicableActionList, getTagName(localName, qName));
@@ -237,17 +245,9 @@
       return;
     }
 
-    if (skip != null) {
-      // getLogger().debug("Skipping invoking begin() method for [{}].",
-      // pattern);
-      return;
-    }
-
     Iterator i = applicableActionList.iterator();
-
     while (i.hasNext()) {
       Action action = (Action) i.next();
-
       // now let us invoke the action. We catch and report any eventual
       // exceptions
       try {


More information about the logback-dev mailing list