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 2017/08/02 23:06:14 UTC
[3/9] tomee git commit: Revert "Check the binding for LazyResources
and Destroyable resources first"
Revert "Check the binding for LazyResources and Destroyable resources first"
This reverts commit 96973e9ac09f96b9fea13b97380a2f82cb157f61.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c3761843
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c3761843
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c3761843
Branch: refs/heads/master
Commit: c3761843e20447fc484843d6d3765d951edda4c3
Parents: 96973e9
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Fri Jul 14 16:57:23 2017 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Fri Jul 14 16:57:23 2017 +0100
----------------------------------------------------------------------
.../openejb/assembler/classic/Assembler.java | 59 ++++++++++----------
1 file changed, 31 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/c3761843/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 13c27e6..d0c0958 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
@@ -2469,40 +2469,43 @@ 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);
-
- final NamingEnumeration<Binding> bindings = globalContext.listBindings(ctx);
- while (bindings.hasMoreElements()) {
- final Binding binding = bindings.nextElement();
- if (!binding.getName().equals(objName)) {
- continue;
- }
- if (DestroyableResource.class.isInstance(binding.getObject())) {
- final DestroyableResource destroyableResource = DestroyableResource.class.cast(binding.getObject());
- destroyableResource.destroyResource();
- globalContext.unbind(name);
- return;
- }
+ final Object object;
- if (!LazyObjectReference.class.isInstance(binding.getObject())) {
- continue;
- }
+ try {
+ object = globalContext.lookup(name);
+ } catch (final NamingException e) {
+ // if we catch a NamingException, 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;
+ }
+ if (DestroyableResource.class.isInstance(binding.getObject())) {
+ final DestroyableResource destroyableResource = DestroyableResource.class.cast(binding.getObject());
+ destroyableResource.destroyResource();
+ globalContext.unbind(name);
+ return;
+ }
- final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
- if (!ref.isInitialized()) {
- globalContext.unbind(name);
- removeResourceInfo(id);
- return;
+ if (!LazyObjectReference.class.isInstance(binding.getObject())) {
+ continue;
+ }
+
+ final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
+ if (! ref.isInitialized()) {
+ globalContext.unbind(name);
+ removeResourceInfo(name);
+ return;
+ }
}
+
+ throw e;
}
- // 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 = "?";