You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2016/04/04 00:15:21 UTC
[3/3] tomee git commit: Check for LazyObjectReference first
Check for LazyObjectReference first
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/209378d3
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/209378d3
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/209378d3
Branch: refs/heads/tomee-1.7.x
Commit: 209378d3913bd75076b3cbd5a931e3a27d84ac7d
Parents: 8610ae1
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Fri Apr 1 23:27:04 2016 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Fri Apr 1 23:27:04 2016 +0100
----------------------------------------------------------------------
.../openejb/assembler/classic/Assembler.java | 47 +++++++++-----------
1 file changed, 21 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/209378d3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index dd29878..8464957 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -2253,38 +2253,33 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
}
private void destroyLookedUpResource(final Context globalContext, final String id, final String name) throws NamingException {
+ // check to see if the resource is a LazyObjectReference that has not been initialized
+ // if it is, we'll remove the LazyObjectReference, rather than do a lookup causing it
+ // to be instantiated
+ final String ctx = name.substring(0, name.lastIndexOf("/"));
+ final String objName = name.substring(ctx.length() + 1);
- Object object = null;
-
- try {
- object = globalContext.lookup(name);
- } catch (final Exception e) {
- // if we catch an Exception, check to see if the resource is a LaztObjectReference that has not been initialized correctly
- final String ctx = name.substring(0, name.lastIndexOf("/"));
- final String objName = name.substring(ctx.length() + 1);
+ final NamingEnumeration<Binding> bindings = globalContext.listBindings(ctx);
+ while (bindings.hasMoreElements()) {
+ final Binding binding = bindings.nextElement();
+ if (!binding.getName().equals(objName)) {
+ continue;
+ }
- final NamingEnumeration<Binding> bindings = globalContext.listBindings(ctx);
- while (bindings.hasMoreElements()) {
- final Binding binding = bindings.nextElement();
- if (!binding.getName().equals(objName)) {
- continue;
- }
-
- if (!LazyObjectReference.class.isInstance(binding.getObject())) {
- continue;
- }
-
- final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
- if (! ref.isInitialized()) {
- globalContext.unbind(name);
- removeResourceInfo(name);
- return;
- }
+ if (!LazyObjectReference.class.isInstance(binding.getObject())) {
+ continue;
}
- throw new NamingException(e.getMessage());
+ final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
+ if (! ref.isInitialized()) {
+ globalContext.unbind(name);
+ removeResourceInfo(name);
+ return;
+ }
}
+ // otherwise, look the object up and remove it
+ final Object object = globalContext.lookup(name);
final String clazz;
if (object == null) { // should it be possible?
clazz = "?";