Try to fix NullPointerException in NodeProxy.getNode().

This commit is contained in:
hns 2009-04-20 11:07:55 +00:00
parent 4875a85fce
commit b0478b020b

View file

@ -1148,20 +1148,23 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco
if (node == null || node.getState() == Node.INVALID) { if (node == null || node.getState() == Node.INVALID) {
if (handle != null) { if (handle != null) {
node = handle.getNode(core.app.getWrappedNodeManager()); node = handle.getNode(core.app.getWrappedNodeManager());
String protoname = node.getPrototype(); if (node != null) {
// the actual prototype name may vary from the node handle's prototype name String protoname = node.getPrototype();
if (className == null || !className.equals(protoname)) { // the actual prototype name may vary from the node handle's prototype name
Scriptable proto = core.getValidPrototype(protoname); if (className == null || !className.equals(protoname)) {
if (proto == null) { Scriptable proto = core.getValidPrototype(protoname);
protoname = "HopObject"; if (proto == null) {
proto = core.getValidPrototype("HopObject"); 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 if (node == null || node.getState() == Node.INVALID) {
// to avoid throwing an exception. // We probably have a deleted node.
// Replace with empty transient node to avoid throwing an exception.
node = new Node("DeletedNode", null, core.app.getWrappedNodeManager()); node = new Node("DeletedNode", null, core.app.getWrappedNodeManager());
} }
} }