From 1c7138c4dfbc65b68862f53d156cfaaed4415788 Mon Sep 17 00:00:00 2001 From: Scokart Gilles Date: Tue, 19 Aug 2008 15:05:07 +0000 Subject: [PATCH] fix very unlikely thread safety issue (may occur if PropertyHelperTask is used in a parallel, which would be a strange use case) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@687070 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/PropertyHelper.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/org/apache/tools/ant/PropertyHelper.java b/src/main/org/apache/tools/ant/PropertyHelper.java index 3ec73e504..670db09ef 100644 --- a/src/main/org/apache/tools/ant/PropertyHelper.java +++ b/src/main/org/apache/tools/ant/PropertyHelper.java @@ -177,7 +177,7 @@ public class PropertyHelper implements GetProperty { private Project project; private PropertyHelper next; - private Hashtable delegates = new Hashtable(); + private volatile Hashtable delegates = new Hashtable(); /** Project properties map (usually String to String). */ private Hashtable properties = new Hashtable(); @@ -949,8 +949,9 @@ public class PropertyHelper implements GetProperty { * @since Ant 1.8 */ protected List getDelegates(Class type) { - return delegates.containsKey(type) - ? (List) new ArrayList((List) delegates.get(type)) : Collections.EMPTY_LIST; + Hashtable curDelegates = delegates; + return curDelegates.containsKey(type) + ? (List) new ArrayList((List) curDelegates.get(type)) : Collections.EMPTY_LIST; } /**