fixing NameNode in case subtree has been unbound
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5055c7fe Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5055c7fe Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5055c7fe Branch: refs/heads/tomee-7.0.0-M1 Commit: 5055c7fe59145a78a5b8d35ca0ca20fe960dfb12 Parents: a702d89 Author: Romain Manni-Bucau <rmann...@gmail.com> Authored: Mon Oct 26 08:22:10 2015 +0100 Committer: Romain Manni-Bucau <rmann...@gmail.com> Committed: Mon Oct 26 08:22:10 2015 +0100 ---------------------------------------------------------------------- .../apache/openejb/core/ivm/naming/NameNode.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/5055c7fe/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NameNode.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NameNode.java b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NameNode.java index cb728e1..46e6766 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NameNode.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/NameNode.java @@ -38,6 +38,7 @@ public class NameNode implements Serializable { private Object myObject; private transient IvmContext myContext; private boolean unbound; + private boolean subTreeUnbound; public NameNode(final NameNode parent, final ParsedName name, final Object obj, final NameNode parentTree) { atomicName = name.getComponent(); @@ -74,7 +75,7 @@ public class NameNode implements Serializable { NameNotFoundException n = null; final int pos = name.getPos(); if (compareResult == ParsedName.IS_EQUAL && name.getComponent().equals(atomicName)) { - // hashcodes and String valuse are equal + // hashcodes and String values are equal if (name.next()) { if (subTree != null) { try { @@ -82,9 +83,9 @@ public class NameNode implements Serializable { } catch (final NameNotFoundException e) { n = e; } - } else if (!unbound && myObject == null) { + } else if (!subTreeUnbound && !unbound && myContext != null) { try { - return IvmContext.class.cast(getBinding()).mynode.resolve(name); + return myContext.mynode.resolve(name); } catch (final NameNotFoundException e) { n = e; } @@ -143,6 +144,7 @@ public class NameNode implements Serializable { } if (subTree == null) { subTree = new NameNode(this, name, obj, this); + subTreeUnbound = false; } else { subTree.bind(name, obj); } @@ -228,6 +230,7 @@ public class NameNode implements Serializable { if (compareResult == ParsedName.IS_EQUAL) { if (subTree == null) { subTree = node; + subTreeUnbound = false; subTree.parentTree = this; } else { subTree.bind(node); @@ -277,17 +280,18 @@ public class NameNode implements Serializable { private void unbind(final NameNode node) { if (subTree == node) { subTree = null; + subTreeUnbound = true; } else if (grtrTree == node) { grtrTree = null; } else if (lessTree == node) { lessTree = null; } - rebalance(this, node); + rebalance(node); } - private void rebalance(final NameNode tree, final NameNode node) { + private void rebalance(final NameNode node) { if (node.subTree != null) { - tree.bind(node.subTree); + this.bind(node.subTree); } if (node.lessTree != null) { this.bind(node.lessTree);