ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1390160 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/impl/builder/ axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/
Date Tue, 25 Sep 2012 21:35:38 GMT
Author: veithen
Date: Tue Sep 25 21:35:38 2012
New Revision: 1390160

URL: http://svn.apache.org/viewvc?rev=1390160&view=rev
Log:
Added a feature to debug situations as described in AXIOM-439; it allows to determine where
a node has been discarded/consumed.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeHelper.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java?rev=1390160&r1=1390159&r2=1390160&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
Tue Sep 25 21:35:38 2012
@@ -46,6 +46,7 @@ import javax.xml.stream.XMLStreamReader;
 
 import java.io.InputStream;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
@@ -112,6 +113,12 @@ public abstract class StAXBuilder implem
     protected Exception parserException;
     
     /**
+     * Stores the stack trace of the code that caused a node to be discarded or consumed.
This is
+     * only used if debug logging was enabled when builder was created.
+     */
+    private final Map/*<OMContainer,Throwable>*/ discardTracker = log.isDebugEnabled()
? new LinkedHashMap() : null;
+    
+    /**
      * Constructor StAXBuilder.
      * This constructor is used if the parser is at the beginning (START_DOCUMENT).
      *
@@ -273,6 +280,27 @@ public abstract class StAXBuilder implem
         }
     }
 
+    private void discarded(OMContainerEx container) {
+        container.discarded();
+        if (discardTracker != null) {
+            discardTracker.put(container, new Throwable());
+        }
+    }
+    
+    /**
+     * For internal use only.
+     * 
+     * @param container
+     */
+    public void debugDiscarded(Object container) {
+        if (log.isDebugEnabled() && discardTracker != null) {
+            Throwable t = (Throwable)discardTracker.get(container);
+            if (t != null) {
+                log.debug("About to throw NodeUnavailableException. Location of the code
that caused the node to be discarded/consumed:", t);
+            }
+        }
+    }
+    
     // For compatibility only
     public void discard(OMElement element) throws OMException {
         discard((OMContainer)element);
@@ -314,7 +342,7 @@ public abstract class StAXBuilder implem
             // Mark nodes as discarded
             OMContainerEx current = target;
             while (true) {
-                current.discarded();
+                discarded(current);
                 if (current == container) {
                     break;
                 }
@@ -508,7 +536,7 @@ public abstract class StAXBuilder implem
             // Mark all containers in the hierarchy as discarded because they can no longer
be built
             OMContainerEx current = target;
             while (current != null) {
-                current.discarded();
+                discarded(current);
                 if (current instanceof OMElement) {
                     current = (OMContainerEx)((OMElement)current).getParent();
                 } else {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java?rev=1390160&r1=1390159&r2=1390160&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
Tue Sep 25 21:35:38 2012
@@ -29,6 +29,7 @@ import org.apache.axiom.om.OMXMLStreamRe
 import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.builder.OMFactoryEx;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.OMXMLStreamReaderValidator;
 import org.apache.commons.logging.Log;
@@ -174,6 +175,7 @@ public final class OMContainerHelper {
         if (firstChild == null) {
             switch (that.getState()) {
                 case IParentNode.DISCARDED:
+                    ((StAXBuilder)that.getBuilder()).debugDiscarded(that);
                     throw new NodeUnavailableException();
                 case IParentNode.INCOMPLETE:
                     do {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeHelper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeHelper.java?rev=1390160&r1=1390159&r2=1390160&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeHelper.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeHelper.java
Tue Sep 25 21:35:38 2012
@@ -21,6 +21,7 @@ package org.apache.axiom.om.impl.common;
 import org.apache.axiom.om.NodeUnavailableException;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
 
 public final class OMNodeHelper {
     private OMNodeHelper() {}
@@ -32,6 +33,7 @@ public final class OMNodeHelper {
             if (parent != null && parent.getBuilder() != null) {
                 switch (parent.getState()) {
                     case IParentNode.DISCARDED:
+                        ((StAXBuilder)parent.getBuilder()).debugDiscarded(parent);
                         throw new NodeUnavailableException();
                     case IParentNode.INCOMPLETE:
                         do {



Mime
View raw message