openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1680101 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context: AbstractContext.java RequestContext.java
Date Mon, 18 May 2015 21:10:34 GMT
Author: struberg
Date: Mon May 18 21:10:33 2015
New Revision: 1680101

URL: http://svn.apache.org/r1680101
Log:
fix BeanBag handling in concurrent cases and RequestContext

RequestContext doesn't need to be a ConcurrentHashMap.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java?rev=1680101&r1=1680100&r2=1680101&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java
Mon May 18 21:10:33 2015
@@ -63,23 +63,24 @@ public abstract class AbstractContext im
     protected Class<? extends Annotation> scopeType;
 
     @SuppressWarnings("unchecked")
-    private <T> void createContextualBag(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+    private <T> BeanInstanceBag<T> createContextualBag(Contextual<T> contextual,
CreationalContext<T> creationalContext)
     {
         BeanInstanceBag<T> bag = new BeanInstanceBag<T>(creationalContext);
         
         if(componentInstanceMap instanceof ConcurrentMap)
         {
-            T exist = (T) ((ConcurrentMap) componentInstanceMap).putIfAbsent(contextual,
bag);
-            //no instance
-            if(exist == null)
+            BeanInstanceBag<?> existingBag = ((ConcurrentMap<Contextual<?>,
BeanInstanceBag<?>>) componentInstanceMap).putIfAbsent(contextual, bag);
+            if (existingBag != null)
             {
-                componentInstanceMap.put(contextual, bag);
+                bag = (BeanInstanceBag<T>) existingBag;
             }
         }
         else
         {
             componentInstanceMap.put(contextual, bag);
-        }                
+        }
+
+        return bag;
     }
     
     /**
@@ -136,8 +137,7 @@ public abstract class AbstractContext im
         BeanInstanceBag<T> bag = (BeanInstanceBag<T>)componentInstanceMap.get(contextual);
         if(bag == null)
         {
-            createContextualBag(contextual, creationalContext);
-            bag = (BeanInstanceBag<T>)componentInstanceMap.get(contextual);
+            bag = createContextualBag(contextual, creationalContext);
         }
 
         //Look for instance

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java?rev=1680101&r1=1680100&r2=1680101&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
Mon May 18 21:10:33 2015
@@ -18,7 +18,7 @@
  */
 package org.apache.webbeans.context;
 
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.HashMap;
 
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.spi.Contextual;
@@ -50,7 +50,7 @@ public class RequestContext extends Abst
     @Override
     public void setComponentInstanceMap()
     {
-        componentInstanceMap = new ConcurrentHashMap<Contextual<?>, BeanInstanceBag<?>>();
+        componentInstanceMap = new HashMap<Contextual<?>, BeanInstanceBag<?>>();
     }
 
     /**



Mime
View raw message