Browse Source

Properties.propertyNames() should be used instead of .keys():

fix for previous fix - use getProperty() and not get()
fix for PropertySet
PR: 27261


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276971 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
39868ef368
3 changed files with 20 additions and 5 deletions
  1. +2
    -2
      src/main/org/apache/tools/ant/Project.java
  2. +2
    -2
      src/main/org/apache/tools/ant/types/CommandlineJava.java
  3. +16
    -1
      src/main/org/apache/tools/ant/types/PropertySet.java

+ 2
- 2
src/main/org/apache/tools/ant/Project.java View File

@@ -830,8 +830,8 @@ public class Project {
Properties systemP = System.getProperties();
Enumeration e = systemP.propertyNames();
while (e.hasMoreElements()) {
Object name = e.nextElement();
String value = systemP.get(name).toString();
String name = (String) e.nextElement();
String value = systemP.getProperty(name);
this.setPropertyInternal(name.toString(), value);
}
}


+ 2
- 2
src/main/org/apache/tools/ant/types/CommandlineJava.java View File

@@ -134,8 +134,8 @@ public class CommandlineJava implements Cloneable {
sys = System.getProperties();
Properties p = new Properties();
for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) {
Object o = e.nextElement();
p.put(o, sys.get(o));
String name = (String) e.nextElement();
p.put(name, sys.getProperty(name));
}
p.putAll(mergePropertySets());
for (Enumeration e = variables.elements(); e.hasMoreElements();) {


+ 16
- 1
src/main/org/apache/tools/ant/types/PropertySet.java View File

@@ -173,6 +173,21 @@ public class PropertySet extends DataType {
return isReference() ? getRef()._mapper : _mapper;
}

/**
* Convert the system properties to a hashtable.
* Use propertynames to get the list of properties (including
* default ones).
*/
private Hashtable getAllSystemProperties() {
Hashtable ret = new Hashtable();
for (Enumeration e = System.getProperties().propertyNames();
e.hasMoreElements();) {
String name = (String) e.nextElement();
ret.put(name, System.getProperties().getProperty(name));
}
return ret;
}

/**
* this is the operation to get the existing or recalculated properties.
* @return
@@ -181,7 +196,7 @@ public class PropertySet extends DataType {
Set names = null;
Project prj = getProject();
Hashtable props =
prj == null ? System.getProperties() : prj.getProperties();
prj == null ? getAllSystemProperties() : prj.getProperties();

if (getDynamic() || cachedNames == null) {
names = new HashSet();


Loading…
Cancel
Save