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 2018/12/06 17:32:43 UTC

[4/5] tomee git commit: TOMEE-2322 restore previous classloader at the end

TOMEE-2322 restore previous classloader at the end


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

Branch: refs/heads/master
Commit: 3c8038a32a0c06eefdbbc0b1e7cd17a3c61fbe69
Parents: 14e5a2b
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 15:09:10 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 15:09:10 2018 +0000

----------------------------------------------------------------------
 .../src/main/java/org/apache/openejb/cli/Bootstrap.java        | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3c8038a3/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
index 63c0b9f..9582fcb 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
@@ -172,10 +172,12 @@ public class Bootstrap {
      * Read commands from BASE_PATH (using XBean's ResourceFinder) and execute the one specified on the command line
      */
     public static void main(final String[] args) throws Exception {
+        ClassLoader cl = null;
         setupHome(args);
         try (final URLClassLoader loader = setupClasspath()) {
 
             if (loader != null) {
+                cl = Thread.currentThread().getContextClassLoader();
                 Thread.currentThread().setContextClassLoader(loader);
                 if (loader != ClassLoader.getSystemClassLoader()) {
                     System.setProperty("openejb.classloader.first.disallow-system-loading", "true");
@@ -197,6 +199,10 @@ public class Bootstrap {
                 throw Error.class.cast(cause);
             }
             throw new IllegalStateException(cause);
+        } finally {
+            if (cl != null) {
+                Thread.currentThread().setContextClassLoader(cl);
+            }
         }
     }
 }