From efef302a3da9a9e063da729c92f6f2b997884a9a Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Thu, 27 Nov 2003 10:16:13 +0000 Subject: [PATCH] Allow references and properties to be null without causing NPE in BSF git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275699 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/util/ScriptRunner.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/util/ScriptRunner.java b/src/main/org/apache/tools/ant/util/ScriptRunner.java index e962bb806..7e876c5c3 100644 --- a/src/main/org/apache/tools/ant/util/ScriptRunner.java +++ b/src/main/org/apache/tools/ant/util/ScriptRunner.java @@ -139,7 +139,15 @@ public class ScriptRunner { for (Iterator i = beans.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); Object value = beans.get(key); - manager.declareBean(key, value, value.getClass()); + if (value != null) { + manager.declareBean(key, value, value.getClass()); + } else { + // BSF uses a hashtable to store values + // so cannot declareBean with a null value + // So need to remove any bean of this name as + // that bean should not be visible + manager.undeclareBean(key); + } } // execute the script