openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject svn commit: r1421886 - /openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Date Fri, 14 Dec 2012 14:26:31 GMT
Author: tandraschko
Date: Fri Dec 14 14:26:30 2012
New Revision: 1421886

URL: http://svn.apache.org/viewvc?rev=1421886&view=rev
Log:
(OWB-736) NPE while removing dependent beans

Modified:
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java

Modified: openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=1421886&r1=1421885&r2=1421886&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
(original)
+++ openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Fri Dec 14 14:26:30 2012
@@ -211,22 +211,25 @@ public class CreationalContextImpl<T> im
 
         synchronized(this)
         {
-            List<DependentCreationalContext<?>> values = dependentObjects.get(ownerInstance);
-            if(values != null && !values.isEmpty())
+            if (dependentObjects != null)
             {
-                Iterator<DependentCreationalContext<?>> it = values.iterator();
-                while(it.hasNext())
+                List<DependentCreationalContext<?>> values = dependentObjects.get(ownerInstance);
+                if (values != null && !values.isEmpty())
                 {
-                    DependentCreationalContext<?> dc = it.next();
-                    if(dc.getDependentType().equals(DependentType.INTERCEPTOR) &&
-                       dc.getContextual().equals(interceptor))
+                    Iterator<DependentCreationalContext<?>> it = values.iterator();
+                    while (it.hasNext())
                     {
-                        return dc.getInstance();
+                        DependentCreationalContext<?> dc = it.next();
+                        if (dc.getDependentType().equals(DependentType.INTERCEPTOR) &&
+                                dc.getContextual().equals(interceptor))
+                        {
+                            return dc.getInstance();
+                        }
                     }
-
                 }
             }
         }
+        
         return null;
     }
 
@@ -246,18 +249,21 @@ public class CreationalContextImpl<T> im
 
         synchronized(this)
         {
-            List<DependentCreationalContext<?>> values = dependentObjects.get(ownerInstance);
-            if (values != null && values.size() > 0)
+            if (dependentObjects != null)
             {
-                Iterator<DependentCreationalContext<?>> it = values.iterator();
-                while (it.hasNext())
+                List<DependentCreationalContext<?>> values = dependentObjects.get(ownerInstance);
+                if (values != null && values.size() > 0)
                 {
-                    DependentCreationalContext<?> dc = it.next();
-
-                    if(dc.getDependentType().equals(DependentType.DECORATOR) &&
-                       dc.getContextual().equals(decorator))
+                    Iterator<DependentCreationalContext<?>> it = values.iterator();
+                    while (it.hasNext())
                     {
-                        return dc.getInstance();
+                        DependentCreationalContext<?> dc = it.next();
+
+                        if (dc.getDependentType().equals(DependentType.DECORATOR) &&
+                                dc.getContextual().equals(decorator))
+                        {
+                            return dc.getInstance();
+                        }
                     }
                 }
             }
@@ -278,32 +284,35 @@ public class CreationalContextImpl<T> im
 
         synchronized(this)
         {
-            Collection<List<DependentCreationalContext<?>>> values = dependentObjects.values();
-            if(values != null)
+            if (dependentObjects != null)
             {
-                for(List<DependentCreationalContext<?>> value : values)
+                Collection<List<DependentCreationalContext<?>>> values
= dependentObjects.values();
+                if (values != null)
                 {
-                    // this is kind of an emergency valve...
-                    int maxRemoval = value.size() * 3;
-                    while(!value.isEmpty() && maxRemoval > 0)
+                    for (List<DependentCreationalContext<?>> value : values)
                     {
-                        // we don't use an iterator because the destroyal might register
a 
-                        // fresh PreDestroy interceptor as dependent object...
-                        DependentCreationalContext<T> dependent = (DependentCreationalContext<T>)value.get(0);
-                        dependent.getContextual().destroy((T)dependent.getInstance(), this);
+                        // this is kind of an emergency valve...
+                        int maxRemoval = value.size() * 3;
+                        while (!value.isEmpty() && maxRemoval > 0)
+                        {
+                            // we don't use an iterator because the destroyal might register
a 
+                            // fresh PreDestroy interceptor as dependent object...
+                            DependentCreationalContext<T> dependent = (DependentCreationalContext<T>)
value.get(0);
+                            dependent.getContextual().destroy((T) dependent.getInstance(),
this);
                         
-                        value.remove(0);
-                        maxRemoval--;
-                    }
+                            value.remove(0);
+                            maxRemoval--;
+                        }
                     
-                    if (maxRemoval == 0)
-                    {
-                        throw new WebBeansException("infinite loop detected while destroying
bean " + contextual);
+                        if (maxRemoval == 0)
+                        {
+                            throw new WebBeansException("infinite loop detected while destroying
bean " + contextual);
+                        }
                     }
                 }
-            }
 
-            dependentObjects = null;
+                dependentObjects = null;
+            }
         }
 
         // the instances are managed as normal dependent instances already



Mime
View raw message