openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1607153 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/event/ webbeans-impl/src/main/java/org/apache/webbeans/portable/ webbeans-impl/src/main/java/org/apache/webbeans/util/ webbeans-tck/
Date Tue, 01 Jul 2014 17:56:14 GMT
Author: rmannibucau
Date: Tue Jul  1 17:56:14 2014
New Revision: 1607153

URL: http://svn.apache.org/r1607153
Log:
event select(TypeLiteral) should validate there is no typevaraible

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/LazyInterceptorDefinedInjectionTarget.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-tck/testng-dev.xml

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java?rev=1607153&r1=1607152&r2=1607153&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
Tue Jul  1 17:56:14 2014
@@ -95,9 +95,10 @@ public class EventMetadataImpl implement
     
     public EventMetadata select(TypeLiteral<?> subtype, Annotation... bindings)
     {
+        webBeansContext.getWebBeansUtil().checkTypeVariables(subtype);
         return select(subtype.getType(), bindings);
     }
-    
+
     public EventMetadata select(Type subtype, Annotation... bindings)
     {
         Set<Annotation> newQualifiers = ArrayUtil.asSet(bindings);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/LazyInterceptorDefinedInjectionTarget.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/LazyInterceptorDefinedInjectionTarget.java?rev=1607153&r1=1607152&r2=1607153&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/LazyInterceptorDefinedInjectionTarget.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/LazyInterceptorDefinedInjectionTarget.java
Tue Jul  1 17:56:14 2014
@@ -31,8 +31,6 @@ import java.util.Set;
 
 public class LazyInterceptorDefinedInjectionTarget<T> extends InjectionTargetImpl<T>
 {
-    private volatile boolean interceptorsDefined;
-
     public LazyInterceptorDefinedInjectionTarget(final AnnotatedType<T> annotatedType,
                                                  final Set<InjectionPoint> injectionPoints,
                                                  final WebBeansContext webBeansContext,
@@ -40,27 +38,18 @@ public class LazyInterceptorDefinedInjec
                                                  final List<AnnotatedMethod<?>>
preDestroyMethods)
     {
         super(annotatedType, injectionPoints, webBeansContext, postConstructMethods, preDestroyMethods);
-        interceptorsDefined = false;
     }
 
-    @Override
+    @Override // TODO: this is not thread safe
     public T produce(final CreationalContext<T> creationalContext)
     {
+        interceptorInfo = null;
+        proxyClass = null;
         final CreationalContextImpl<T> creationalContextImpl = (CreationalContextImpl<T>)
creationalContext;
-        if (interceptorInfo == null && !interceptorsDefined)
+        final Bean<T> bean = creationalContextImpl.getBean();
+        if (bean != null)
         {
-            final Bean<T> bean = creationalContextImpl.getBean();
-            if (bean != null)
-            {
-                synchronized (this)
-                {
-                    if (!interceptorsDefined)
-                    {
-                        defineInterceptorStack(bean, annotatedType, webBeansContext);
-                        interceptorsDefined = true;
-                    }
-                }
-            }
+            defineInterceptorStack(bean, annotatedType, webBeansContext);
         }
         return super.produce(creationalContext);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1607153&r1=1607152&r2=1607153&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Tue Jul  1 17:56:14 2014
@@ -86,6 +86,7 @@ import javax.enterprise.inject.IllegalPr
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.*;
+import javax.enterprise.util.TypeLiteral;
 import javax.inject.Inject;
 import javax.inject.Named;
 
@@ -107,6 +108,8 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.logging.Logger;
 
 /**
@@ -118,6 +121,7 @@ public final class WebBeansUtil
     private static final Logger logger = WebBeansLoggerFacade.getLogger(WebBeansUtil.class);
 
     private final WebBeansContext webBeansContext;
+    private final ConcurrentMap<Type, Boolean> noTypeVariables = new ConcurrentHashMap<Type,
Boolean>();
 
     public WebBeansUtil(WebBeansContext webBeansContext)
     {
@@ -1577,4 +1581,31 @@ public final class WebBeansUtil
             }
         }
     }
+
+    public void checkTypeVariables(final TypeLiteral<?> subtype)
+    {
+        final Type t = subtype.getType();
+        Boolean result = noTypeVariables.get(t);
+        if (result != null)
+        {
+            if (!result)
+            {
+                throw new IllegalArgumentException(t + " has a TypeVariable which is forbidden");
+            }
+            return;
+        }
+
+        if (ParameterizedType.class.isInstance(t))
+        {
+            for (final Type arg : ParameterizedType.class.cast(t).getActualTypeArguments())
+            {
+                if (TypeVariable.class.isInstance(arg))
+                {
+                    noTypeVariables.putIfAbsent(t, false);
+                    throw new IllegalArgumentException(arg + " is a TypeVariable which is
forbidden");
+                }
+            }
+        }
+        noTypeVariables.putIfAbsent(t, true);
+    }
 }

Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1607153&r1=1607152&r2=1607153&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original)
+++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Tue Jul  1 17:56:14 2014
@@ -18,8 +18,9 @@
 <suite name="JSR-346-TCK" verbose="2" configfailurepolicy="continue">
   <test name="JSR-346 TCK">
     <classes>
+      <class name="org.jboss.cdi.tck.tests.event.select.SelectEventTest" />
       <class
-          name="org.jboss.cdi.tck.tests.event.select.SelectEventTest" />
+          name="org.jboss.cdi.tck.tests.event.parameterized.ParameterizedEventTest" />
     </classes>
     <groups>
       <run>



Mime
View raw message