openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1814565 - /openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit/MeecrowaveRuleBase.java
Date Wed, 08 Nov 2017 10:21:41 GMT
Author: struberg
Date: Wed Nov  8 10:21:40 2017
New Revision: 1814565

URL: http://svn.apache.org/viewvc?rev=1814565&view=rev
Log:
MEECROWAVE-77 fix OWB SingletonService existence check

Modified:
    openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit/MeecrowaveRuleBase.java

Modified: openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit/MeecrowaveRuleBase.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit/MeecrowaveRuleBase.java?rev=1814565&r1=1814564&r2=1814565&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit/MeecrowaveRuleBase.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-junit/src/main/java/org/apache/meecrowave/junit/MeecrowaveRuleBase.java
Wed Nov  8 10:21:40 2017
@@ -22,6 +22,7 @@ import org.apache.meecrowave.Meecrowave;
 import org.apache.meecrowave.internal.ClassLoaderLock;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.corespi.DefaultSingletonService;
 import org.apache.webbeans.spi.SingletonService;
 import org.junit.rules.TestRule;
 import org.junit.runner.Description;
@@ -112,12 +113,25 @@ public abstract class MeecrowaveRuleBase
                 currentCL = this.getClass().getClassLoader();
             }
 
-            final SingletonService<WebBeansContext> singletonInstance = WebBeansFinder.getSingletonService();
-            synchronized (singletonInstance) {
+            final SingletonService<WebBeansContext> singletonService = WebBeansFinder.getSingletonService();
+            synchronized (singletonService) {
                 try {
-                    singletonInstance.get(currentCL);
-                    meecrowaveCL = currentCL;
-                } catch (final IllegalArgumentException iae) {
+                    if (singletonService instanceof DefaultSingletonService) {
+                        synchronized (singletonService) {
+                            ((DefaultSingletonService) singletonService).register(currentCL,
null);
+                            // all fine, it seems we do not have an OWB container for this
ClassLoader yet
+
+                            // let's reset it then ;
+                            ((DefaultSingletonService) singletonService).clear(currentCL);
+                        }
+                        meecrowaveCL = currentCL;
+                    }
+                }
+                catch (IllegalArgumentException iae) {
+                    // whoops there is already an OWB container registered for this very
ClassLoader
+                }
+
+                if (meecrowaveCL == null) {
                     meecrowaveCL = new ClassLoader(currentCL) {};
                 }
             }



Mime
View raw message