From 39868ef36807b9456eac82fc6210be649f744eea Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Thu, 28 Oct 2004 09:12:02 +0000 Subject: [PATCH] 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 --- src/main/org/apache/tools/ant/Project.java | 4 ++-- .../apache/tools/ant/types/CommandlineJava.java | 4 ++-- .../org/apache/tools/ant/types/PropertySet.java | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index f310f1cc5..af621222d 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -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); } } diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java index 882f09025..7c92ca2f8 100644 --- a/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -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();) { diff --git a/src/main/org/apache/tools/ant/types/PropertySet.java b/src/main/org/apache/tools/ant/types/PropertySet.java index 81955bf49..e31ef019c 100644 --- a/src/main/org/apache/tools/ant/types/PropertySet.java +++ b/src/main/org/apache/tools/ant/types/PropertySet.java @@ -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();