From 1d2784e6d5429505b3b420e342992c22cd5373a6 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Sun, 3 Mar 2002 10:06:30 +0000 Subject: [PATCH] Answered my own previous question concerning thread safety. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271709 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/XmlLogger.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/org/apache/tools/ant/XmlLogger.java b/src/main/org/apache/tools/ant/XmlLogger.java index ea0ad20d4..62d4f2071 100644 --- a/src/main/org/apache/tools/ant/XmlLogger.java +++ b/src/main/org/apache/tools/ant/XmlLogger.java @@ -74,7 +74,13 @@ import org.apache.tools.ant.util.StringUtils; * Generates a file in the current directory with * an XML description of what happened during a build. * The default filename is "log.xml", but this can be overridden - * with the property XmlLogger.file + * with the property XmlLogger.file. + * + * This implementation assumes in its sanity checking that only one + * thread runs a particular target/task at a time. This is enforced + * by the way that parallel builds and antcalls are done - and + * indeed all but the simplest of tasks could run into problems + * if executed in parallel. * * @see Project#addBuildListener(BuildListener) */ @@ -119,14 +125,6 @@ public class XmlLogger implements BuildListener { /** The complete log document for this build. */ private Document doc = builder.newDocument(); - // XXX: (Jon Skeet) I don't see the use for these maps, myself, - // and they don't seem threadsafe to me. Is there something - // preventing a task being executed by two different threads - // at the same time? If not, we could get a mismatch error - // for no good reason. I'd have thought that checking - // the information in the element stored in the TimedElement - // would give enough of a validity check and end up being more - // threadsafe. /** Mapping for when tasks started (Task to TimedElement). */ private Hashtable tasks = new Hashtable(); /** Mapping for when targets started (Task to TimedElement). */