From b0478b020b3f18b8b3d86ba44e6a69f7f83a8c42 Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 20 Apr 2009 11:07:55 +0000 Subject: [PATCH] Try to fix NullPointerException in NodeProxy.getNode(). --- src/helma/scripting/rhino/HopObject.java | 27 +++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/helma/scripting/rhino/HopObject.java b/src/helma/scripting/rhino/HopObject.java index 47b8b245..512f822d 100644 --- a/src/helma/scripting/rhino/HopObject.java +++ b/src/helma/scripting/rhino/HopObject.java @@ -1148,20 +1148,23 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco if (node == null || node.getState() == Node.INVALID) { if (handle != null) { node = handle.getNode(core.app.getWrappedNodeManager()); - String protoname = node.getPrototype(); - // the actual prototype name may vary from the node handle's prototype name - if (className == null || !className.equals(protoname)) { - Scriptable proto = core.getValidPrototype(protoname); - if (proto == null) { - protoname = "HopObject"; - proto = core.getValidPrototype("HopObject"); + if (node != null) { + String protoname = node.getPrototype(); + // the actual prototype name may vary from the node handle's prototype name + if (className == null || !className.equals(protoname)) { + Scriptable proto = core.getValidPrototype(protoname); + if (proto == null) { + protoname = "HopObject"; + proto = core.getValidPrototype("HopObject"); + } + className = protoname; + setPrototype(proto); } - className = protoname; - setPrototype(proto); } - } else { - // we probably have a deleted node. Replace with empty transient node - // to avoid throwing an exception. + } + if (node == null || node.getState() == Node.INVALID) { + // We probably have a deleted node. + // Replace with empty transient node to avoid throwing an exception. node = new Node("DeletedNode", null, core.app.getWrappedNodeManager()); } }