You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rz...@apache.org on 2023/03/29 18:30:39 UTC

[tomee] branch TOMEE-4192-9.x updated: move cleanup code to shared api and add null check to prevent NPE in case of legacy junit rules.

This is an automated email from the ASF dual-hosted git repository.

rzo1 pushed a commit to branch TOMEE-4192-9.x
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/TOMEE-4192-9.x by this push:
     new 9643465593 move cleanup code to shared api and add null check to prevent NPE in case of legacy junit rules.
9643465593 is described below

commit 96434655938723e505734370d2bc4d968fb751ea
Author: G-Ork <ts...@gmail.com>
AuthorDate: Wed Mar 29 16:55:56 2023 +0200

    move cleanup code to shared api and add null check to prevent NPE in
    case of legacy junit rules.
---
 .../org/apache/openejb/testing/ApplicationComposers.java | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
index 7b43b88cba..033e760a7e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
@@ -1106,12 +1106,7 @@ public class ApplicationComposers {
 
             OpenEJB.destroy();
             SystemInstance.reset();
-            /*
-            * Clear additional references
-            */
-            appContext.getWebContexts().clear();
-            appContext.getInjections().clear();
-            appContext.getSystemInstance().removeComponent(TestInstance.class);
+
         } finally {
             runAll(afterRunnables);
             if (originalLoader != null) {
@@ -1158,6 +1153,15 @@ public class ApplicationComposers {
                 // no-op
             }
         }
+        
+        /*
+        * Clear additional references
+        */
+        if (appContext != null) {
+            appContext.getWebContexts().clear();
+            appContext.getInjections().clear();
+            appContext.getSystemInstance().removeComponent(TestInstance.class);
+        }        
     }
 
     private void runAll(final Collection<Runnable> runnables) {