Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 79511 invoked from network); 6 Jun 2002 06:03:37 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 6 Jun 2002 06:03:37 -0000 Received: (qmail 5832 invoked by uid 97); 6 Jun 2002 06:03:44 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 5800 invoked by uid 97); 6 Jun 2002 06:03:43 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 5787 invoked by uid 97); 6 Jun 2002 06:03:43 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 6 Jun 2002 06:03:27 -0000 Message-ID: <20020606060327.34555.qmail@icarus.apache.org> From: stevel@apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/src/main/org/apache/tools/ant Project.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N stevel 2002/06/05 23:03:27 Modified: src/main/org/apache/tools/ant Tag: ANT_15_BRANCH Project.java Log: PR 8793; Need to synchronize core methods in Project. added sync attr to the various setters of Project state. We will take a fractional performance hit on this, even when we arent in parallel mode, which is why I use the synchronized attribute on the setProperty methods; that is ever so slightly faster than syncing on objects inside a method. Revision Changes Path No revision No revision 1.108.2.5 +32 -29 jakarta-ant/src/main/org/apache/tools/ant/Project.java Index: Project.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.108.2.4 retrieving revision 1.108.2.5 diff -u -r1.108.2.4 -r1.108.2.5 --- Project.java 5 Jun 2002 07:14:09 -0000 1.108.2.4 +++ Project.java 6 Jun 2002 06:03:27 -0000 1.108.2.5 @@ -83,7 +83,7 @@ * * @author duncan@x180.com * - * @version $Revision: 1.108.2.4 $ + * @version $Revision: 1.108.2.5 $ */ public class Project { @@ -415,7 +415,7 @@ * @param value The new value of the property. * Must not be null. */ - public void setProperty(String name, String value) { + public synchronized void setProperty(String name, String value) { // command line properties take precedence if (null != userProperties.get(name)) { log("Override ignored for user property " + name, MSG_VERBOSE); @@ -443,7 +443,7 @@ * Must not be null. * @since 1.5 */ - public void setNewProperty(String name, String value) { + public synchronized void setNewProperty(String name, String value) { if (null != properties.get(name)) { log("Override ignored for property " + name, MSG_VERBOSE); return; @@ -462,7 +462,7 @@ * Must not be null. * @see #setProperty(String,String) */ - public void setUserProperty(String name, String value) { + public synchronized void setUserProperty(String name, String value) { log("Setting ro project property: " + name + " -> " + value, MSG_DEBUG); userProperties.put(name, value); @@ -892,23 +892,24 @@ * Must not be null. */ public void addDataTypeDefinition(String typeName, Class typeClass) { - Class old = (Class) dataClassDefinitions.get(typeName); - if (null != old) { - if (old.equals(typeClass)) { - log("Ignoring override for datatype " + typeName - + ", it is already defined by the same class.", - MSG_VERBOSE); - return; - } else { - log("Trying to override old definition of datatype " - + typeName, MSG_WARN); + synchronized(dataClassDefinitions) { + Class old = (Class) dataClassDefinitions.get(typeName); + if (null != old) { + if (old.equals(typeClass)) { + log("Ignoring override for datatype " + typeName + + ", it is already defined by the same class.", + MSG_VERBOSE); + return; + } else { + log("Trying to override old definition of datatype " + + typeName, MSG_WARN); + } } + dataClassDefinitions.put(typeName, typeClass); } - String msg = " +User datatype: " + typeName + " " + typeClass.getName(); log(msg, MSG_DEBUG); - dataClassDefinitions.put(typeName, typeClass); } /** @@ -1676,22 +1677,24 @@ * @param value The value of the reference. Must not be null. */ public void addReference(String name, Object value) { - Object old = references.get(name); - if (old == value) { - // no warning, this is not changing anything - return; - } - if (old != null) { - log("Overriding previous definition of reference to " + name, - MSG_WARN); + synchronized (references) { + Object old = references.get(name); + if (old == value) { + // no warning, this is not changing anything + return; + } + if (old != null) { + log("Overriding previous definition of reference to " + name, + MSG_WARN); + } + log("Adding reference: " + name + " -> " + value, MSG_DEBUG); + references.put(name, value); } - log("Adding reference: " + name + " -> " + value, MSG_DEBUG); - references.put(name, value); } /** * Returns a map of the references in the project (String to Object). - * The returned hashtable is "live" and so should not be modified. + * The returned hashtable is "live" and so must not be modified. * * @return a map of the references in the project (String to Object). */ @@ -1925,9 +1928,9 @@ * * @param thread the thread on which the task is registered. * @param task the task to be registered. - * @since 1.102, Ant 1.5 + * @since Ant 1.5 */ - public void registerThreadTask(Thread thread, Task task) { + public synchronized void registerThreadTask(Thread thread, Task task) { if (task != null) { threadTasks.put(thread, task); } else { -- To unsubscribe, e-mail: For additional commands, e-mail: