From f03f405f04c87c4a3d33dfbd68718498d4708db6 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 26 Sep 2007 12:46:21 +0000 Subject: [PATCH] * Check if changeSet is null in commitCompilation() to avoid NullPointerException. Fixed bug http://helma.org/bugs/show_bug.cgi?id=466 --- src/helma/scripting/rhino/RhinoCore.java | 59 +++++++++++++----------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/helma/scripting/rhino/RhinoCore.java b/src/helma/scripting/rhino/RhinoCore.java index aabbd0c4..27a64375 100644 --- a/src/helma/scripting/rhino/RhinoCore.java +++ b/src/helma/scripting/rhino/RhinoCore.java @@ -889,40 +889,43 @@ public final class RhinoCore implements ScopeProvider { recorder.stopRecording(); Set changedProperties = recorder.getChangeSet(); - recorder.clearChangeSet(); - // ignore all properties that were defined before we started - // compilation. We won't manage these properties, even - // if they were set during compilation. - changedProperties.removeAll(predefinedProperties); + if (changedProperties != null) { + recorder.clearChangeSet(); - // remove all renewed properties from the previously compiled - // property names so we can remove those properties that were not - // renewed in this compilation - compiledProperties.removeAll(changedProperties); + // ignore all properties that were defined before we started + // compilation. We won't manage these properties, even + // if they were set during compilation. + changedProperties.removeAll(predefinedProperties); - boolean isGlobal = "global".equals(frameworkProto.getLowerCaseName()); + // remove all renewed properties from the previously compiled + // property names so we can remove those properties that were not + // renewed in this compilation + compiledProperties.removeAll(changedProperties); - Iterator it = compiledProperties.iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - if (isGlobal && (prototypes.containsKey(key.toLowerCase()) - || "JavaPackage".equals(key))) { - // avoid removing HopObject constructor - predefinedProperties.add(key); - continue; - } - try { - objProto.setAttributes(key, 0); - objProto.delete(key); - } catch (Exception px) { - app.logEvent("Error unsetting property "+key+" on "+ - frameworkProto.getName()); + boolean isGlobal = "global".equals(frameworkProto.getLowerCaseName()); + + Iterator it = compiledProperties.iterator(); + while (it.hasNext()) { + String key = (String) it.next(); + if (isGlobal && (prototypes.containsKey(key.toLowerCase()) + || "JavaPackage".equals(key))) { + // avoid removing HopObject constructor + predefinedProperties.add(key); + continue; + } + try { + objProto.setAttributes(key, 0); + objProto.delete(key); + } catch (Exception px) { + app.logEvent("Error unsetting property "+key+" on "+ + frameworkProto.getName()); + } } + + // update compiled properties + compiledProperties = changedProperties; } - - // update compiled properties - compiledProperties = changedProperties; } // mark this type as updated again so it reflects