openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1606521 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java webbeans-tck/testng-dev.xml
Date Sun, 29 Jun 2014 15:10:53 GMT
Author: rmannibucau
Date: Sun Jun 29 15:10:53 2014
New Revision: 1606521

URL: http://svn.apache.org/r1606521
Log:
only destroyable context should allow destruction of objects using Instance

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
    openwebbeans/trunk/webbeans-tck/testng-dev.xml

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java?rev=1606521&r1=1606520&r2=1606521&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
Sun Jun 29 15:10:53 2014
@@ -283,6 +283,10 @@ public class InstanceImpl<T> implements 
 
     public void destroy(T instance)
     {
+        if (instance == null)
+        {
+            throw new NullPointerException("instance is null, can't be destroyed");
+        }
         if (instance instanceof OwbNormalScopeProxy)
         {
             OwbNormalScopeProxy proxy = (OwbNormalScopeProxy) instance;
@@ -290,7 +294,8 @@ public class InstanceImpl<T> implements 
             NormalScopedBeanInterceptorHandler handler = (NormalScopedBeanInterceptorHandler)provider;
             Bean<T> bean = (Bean<T>)handler.getBean();
             CreationalContext<T> creationalContext = (CreationalContext<T>)parentCreationalContext;
-            Context currentContext = webBeansContext.getContextsService().getCurrentContext(bean.getScope());
+            Class<? extends Annotation> beanScope = bean.getScope();
+            Context currentContext = webBeansContext.getBeanManagerImpl().getContext(beanScope);
             if (currentContext instanceof AlterableContext)
             {
                 AlterableContext alterableContext = (AlterableContext)currentContext;
@@ -298,7 +303,7 @@ public class InstanceImpl<T> implements 
             }
             else
             {
-                bean.destroy(instance, creationalContext);
+                throw new UnsupportedOperationException("Not AlterableContext so you can't
call destroy youself");
             }
         }
         else

Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1606521&r1=1606520&r2=1606521&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original)
+++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Sun Jun 29 15:10:53 2014
@@ -19,7 +19,7 @@
   <test name="JSR-346 TCK">
     <classes>
       <class
-          name="org.jboss.cdi.tck.tests.extensions.alternative.metadata.annotated.AnnotatedTypeAnnotationsTest"/>
+          name="org.jboss.cdi.tck.tests.lookup.dynamic.destroy.normal.DestroyingNormalScopedInstanceTest"/>
     </classes>
     <groups>
       <run>



Mime
View raw message