ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r675993 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW contributors.xml src/main/org/apache/tools/ant/XmlLogger.java
Date Fri, 11 Jul 2008 15:45:53 GMT
Author: bodewig
Date: Fri Jul 11 08:45:53 2008
New Revision: 675993

URL: http://svn.apache.org/viewvc?rev=675993&view=rev
Log:
XmlLogger could lose messages when parallel is used.  PR 25734.  Based on analysis and patch
by Craig Sandvik

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=675993&r1=675992&r2=675993&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=675993&r1=675992&r2=675993&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Jul 11 08:45:53 2008
@@ -101,6 +101,9 @@
    parts, some result sets wouldn't get printed.
    Bugzilla Report 32168.
 
+ * XmlLogger could lose messages if <parallel> is used.
+   Bugzilla Report 25734.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=675993&r1=675992&r2=675993&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Fri Jul 11 08:45:53 2008
@@ -200,6 +200,10 @@
     <last>Ryan</last>
   </name>
   <name>
+    <first>Craig</first>
+    <last>Sandvik</last>
+  </name>
+  <name>
     <first>Curtis</first>
     <last>White</last>
   </name>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java?rev=675993&r1=675992&r2=675993&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java Fri Jul 11 08:45:53 2008
@@ -33,6 +33,7 @@
 import org.apache.tools.ant.util.StringUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 import org.w3c.dom.Text;
 
 /**
@@ -172,7 +173,7 @@
             Text errText = doc.createCDATASection(StringUtils.getStackTrace(t));
             Element stacktrace = doc.createElement(STACKTRACE_TAG);
             stacktrace.appendChild(errText);
-            buildElement.element.appendChild(stacktrace);
+            synchronizedAppend(buildElement.element, stacktrace);
         }
         String outFilename = event.getProject().getProperty("XmlLogger.file");
         if (outFilename == null) {
@@ -267,9 +268,10 @@
                 }
             }
             if (parentElement == null) {
-                buildElement.element.appendChild(targetElement.element);
+                synchronizedAppend(buildElement.element, targetElement.element);
             } else {
-                parentElement.element.appendChild(targetElement.element);
+                synchronizedAppend(parentElement.element,
+                                   targetElement.element);
             }
         }
         targets.remove(target);
@@ -320,9 +322,9 @@
             targetElement = (TimedElement) targets.get(target);
         }
         if (targetElement == null) {
-            buildElement.element.appendChild(taskElement.element);
+            synchronizedAppend(buildElement.element, taskElement.element);
         } else {
-            targetElement.element.appendChild(taskElement.element);
+            synchronizedAppend(targetElement.element, taskElement.element);
         }
         Stack threadStack = getStack();
         if (!threadStack.empty()) {
@@ -394,7 +396,7 @@
             Text errText = doc.createCDATASection(StringUtils.getStackTrace(ex));
             Element stacktrace = doc.createElement(STACKTRACE_TAG);
             stacktrace.appendChild(errText);
-            buildElement.element.appendChild(stacktrace);
+            synchronizedAppend(buildElement.element, stacktrace);
         }
         Text messageText = doc.createCDATASection(event.getMessage());
         messageElement.appendChild(messageText);
@@ -411,9 +413,9 @@
             parentElement = (TimedElement) targets.get(target);
         }
         if (parentElement != null) {
-            parentElement.element.appendChild(messageElement);
+            synchronizedAppend(parentElement.element, messageElement);
         } else {
-            buildElement.element.appendChild(messageElement);
+            synchronizedAppend(buildElement.element, messageElement);
         }
     }
 
@@ -459,4 +461,10 @@
     public void setErrorPrintStream(PrintStream err) {
     }
 
+    private void synchronizedAppend(Node parent, Node child) {
+        synchronized(parent) {
+            parent.appendChild(child);
+        }
+    }
+
 }



Mime
View raw message