Browse Source

Synchonization issues in PropertyHelper. Bugzilla 41353.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@495340 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 18 years ago
parent
commit
bf283617db
2 changed files with 31 additions and 17 deletions
  1. +3
    -1
      WHATSNEW
  2. +28
    -16
      src/main/org/apache/tools/ant/PropertyHelper.java

+ 3
- 1
WHATSNEW View File

@@ -36,7 +36,9 @@ Fixed bugs:


* Strip out all -J arguments to non forking rmic adapters, specifically * Strip out all -J arguments to non forking rmic adapters, specifically
the Sun and Weblogic compilers. the Sun and Weblogic compilers.
Bug report 41349
Bug report 41349

* Synchonization issues in PropertyHelper. Bugzilla 41353.


Other changes: Other changes:
-------------- --------------


+ 28
- 16
src/main/org/apache/tools/ant/PropertyHelper.java View File

@@ -470,7 +470,10 @@ public class PropertyHelper {
* (including user properties). * (including user properties).
*/ */
public Hashtable getProperties() { public Hashtable getProperties() {
return new Hashtable(properties);
//avoid concurrent modification:
synchronized (properties) {
return new Hashtable(properties);
}
// There is a better way to save the context. This shouldn't // There is a better way to save the context. This shouldn't
// delegate to next, it's for backward compatibility only. // delegate to next, it's for backward compatibility only.
} }
@@ -480,7 +483,10 @@ public class PropertyHelper {
* @return a hashtable containing just the user properties * @return a hashtable containing just the user properties
*/ */
public Hashtable getUserProperties() { public Hashtable getUserProperties() {
return new Hashtable(userProperties);
//avoid concurrent modification:
synchronized (userProperties) {
return new Hashtable(userProperties);
}
} }


/** /**
@@ -526,14 +532,17 @@ public class PropertyHelper {
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void copyInheritedProperties(Project other) { public void copyInheritedProperties(Project other) {
Enumeration e = inheritedProperties.keys();
while (e.hasMoreElements()) {
String arg = e.nextElement().toString();
if (other.getUserProperty(arg) != null) {
continue;
//avoid concurrent modification:
synchronized (inheritedProperties) {
Enumeration e = inheritedProperties.keys();
while (e.hasMoreElements()) {
String arg = e.nextElement().toString();
if (other.getUserProperty(arg) != null) {
continue;
}
Object value = inheritedProperties.get(arg);
other.setInheritedProperty(arg, value.toString());
} }
Object value = inheritedProperties.get(arg);
other.setInheritedProperty(arg, value.toString());
} }
} }


@@ -550,14 +559,17 @@ public class PropertyHelper {
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void copyUserProperties(Project other) { public void copyUserProperties(Project other) {
Enumeration e = userProperties.keys();
while (e.hasMoreElements()) {
Object arg = e.nextElement();
if (inheritedProperties.containsKey(arg)) {
continue;
//avoid concurrent modification:
synchronized (userProperties) {
Enumeration e = userProperties.keys();
while (e.hasMoreElements()) {
Object arg = e.nextElement();
if (inheritedProperties.containsKey(arg)) {
continue;
}
Object value = userProperties.get(arg);
other.setUserProperty(arg.toString(), value.toString());
} }
Object value = userProperties.get(arg);
other.setUserProperty(arg.toString(), value.toString());
} }
} }




Loading…
Cancel
Save