tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject tomee git commit: TOMEE-2029 remove finalize code
Date Wed, 05 Apr 2017 22:11:29 GMT
Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x 24ad3c7a8 -> e663ee5c0


TOMEE-2029 remove finalize code

The finalizer runs async at some random time.
Since the cleanup code looks up the *current* container for a ClassLoader
this will likely kill a foreign TomEE container.
This exactly happenes in the DeltaSpike test suite and the reason why
TomEE-1.7.x is broken since 1.7.3.
The finalizer also only gets called if the instance gets garbage collected.
But since the whole Container is managed in a Map<ClassLoader,.> it locks itself
if it doesn't get properly closed and the finalizer would never get called
without any proper shutdown anyway!


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e663ee5c
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e663ee5c
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e663ee5c

Branch: refs/heads/tomee-1.7.x
Commit: e663ee5c0269b58897e77700319962a319955727
Parents: 24ad3c7
Author: Mark Struberg <struberg@apache.org>
Authored: Thu Apr 6 00:07:43 2017 +0200
Committer: Mark Struberg <struberg@apache.org>
Committed: Thu Apr 6 00:07:43 2017 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/openejb/OpenEjbContainer.java | 13 -------------
 .../openejb/core/LocalInitialContextFactory.java       |  1 +
 .../apache/openejb/core/ivm/naming/ContextWrapper.java | 11 -----------
 .../openejb/junit/context/OpenEjbTestContext.java      | 11 -----------
 .../java/org/apache/openejb/client/JNDIContext.java    |  9 ---------
 .../java/org/apache/tomee/RemoteTomEEEJBContainer.java | 11 -----------
 .../java/org/apache/tomee/catalina/OpenEJBContext.java | 10 ----------
 .../apache/tomee/embedded/EmbeddedTomEEContainer.java  | 11 -----------
 8 files changed, 1 insertion(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/e663ee5c/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
b/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
index e127494..ba2d4f8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java
@@ -148,19 +148,6 @@ public final class OpenEjbContainer extends EJBContainer {
         }
     }
 
-    @Override
-    protected void finalize() throws Throwable {
-        try {
-            if (this.equals(instance)) {
-                this.close();
-            }
-        } catch (final Exception e) {
-            //no-op
-        } finally {
-            super.finalize();
-        }
-    }
-
     private static boolean isSingleClose() {
         return OPENEJB_EJBCONTAINER_CLOSE_SINGLE.equals(SystemInstance.get().getProperty(OPENEJB_EJBCONTAINER_CLOSE,
"by-invocation"));
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/e663ee5c/container/openejb-core/src/main/java/org/apache/openejb/core/LocalInitialContextFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/LocalInitialContextFactory.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/LocalInitialContextFactory.java
index ef318e0..4970eb7 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/LocalInitialContextFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/LocalInitialContextFactory.java
@@ -104,6 +104,7 @@ public class LocalInitialContextFactory implements InitialContextFactory
{
 
         try {
             openejb = null;
+            bootedOpenEJB = false;
         } finally {
             l.unlock();
         }

http://git-wip-us.apache.org/repos/asf/tomee/blob/e663ee5c/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java
index fc2f94c..2ff0ac6 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java
@@ -181,15 +181,4 @@ public class ContextWrapper implements Context {
     public void unbind(final String name) throws NamingException {
         context.unbind(name);
     }
-
-    @Override
-    protected void finalize() throws Throwable {
-        try {
-            this.close();
-        } catch (final Exception e) {
-            //no-op
-        } finally {
-            super.finalize();
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/e663ee5c/container/openejb-junit/src/main/java/org/apache/openejb/junit/context/OpenEjbTestContext.java
----------------------------------------------------------------------
diff --git a/container/openejb-junit/src/main/java/org/apache/openejb/junit/context/OpenEjbTestContext.java
b/container/openejb-junit/src/main/java/org/apache/openejb/junit/context/OpenEjbTestContext.java
index df2bf02..26c464b 100644
--- a/container/openejb-junit/src/main/java/org/apache/openejb/junit/context/OpenEjbTestContext.java
+++ b/container/openejb-junit/src/main/java/org/apache/openejb/junit/context/OpenEjbTestContext.java
@@ -134,17 +134,6 @@ public class OpenEjbTestContext implements TestContext {
     }
 
     @Override
-    protected void finalize() throws Throwable {
-        try {
-            this.close();
-        } catch (final Exception e) {
-            //no-op
-        } finally {
-            super.finalize();
-        }
-    }
-
-    @Override
     public void close() {
         try {
             initialContext.close();

http://git-wip-us.apache.org/repos/asf/tomee/blob/e663ee5c/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
index c73cf68..bb6463a 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
@@ -845,15 +845,6 @@ public class JNDIContext implements InitialContextFactory, Context {
         return createSubcontext(name.toString());
     }
 
-    @Override
-    protected void finalize() throws Throwable {
-        try {
-            close();
-        } finally {
-            super.finalize();
-        }
-    }
-
     private static final class SimpleNameParser implements NameParser {
 
         private static final Properties PARSER_PROPERTIES = new Properties();

http://git-wip-us.apache.org/repos/asf/tomee/blob/e663ee5c/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
b/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
index f9e77ed..a061caa 100644
--- a/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
+++ b/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
@@ -53,17 +53,6 @@ public class RemoteTomEEEJBContainer extends EJBContainer {
     private InitialContext context;
 
     @Override
-    protected void finalize() throws Throwable {
-        try {
-            this.close();
-        } catch (final Exception e) {
-            //no-op
-        } finally {
-            super.finalize();
-        }
-    }
-
-    @Override
     public void close() {
         final ReentrantLock lock = LOCK;
         lock.lock();

http://git-wip-us.apache.org/repos/asf/tomee/blob/e663ee5c/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContext.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContext.java
b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContext.java
index 8458672..5664028 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContext.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/OpenEJBContext.java
@@ -290,15 +290,5 @@ public class OpenEJBContext implements Context {
         return threadContext == null || DeployerEjb.class.equals(threadContext.getBeanContext().getBeanClass());
     }
 
-    @Override
-    protected void finalize() throws Throwable {
-        try {
-            this.close();
-        } catch (final Exception e) {
-            //no-op
-        } finally {
-            super.finalize();
-        }
-    }
 }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/e663ee5c/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
index 7d30a4e..2ce7030 100644
--- a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
+++ b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/EmbeddedTomEEContainer.java
@@ -65,17 +65,6 @@ public final class EmbeddedTomEEContainer extends EJBContainer {
     }
 
     @Override
-    protected void finalize() throws Throwable {
-        try {
-            this.close();
-        } catch (final Exception e) {
-            //no-op
-        } finally {
-            super.finalize();
-        }
-    }
-
-    @Override
     public void close() {
 
         final ReentrantLock lock = LOCK;


Mime
View raw message