This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git


The following commit(s) were added to refs/heads/main by this push:
     new 5f994ec3f OWB-1417 More than 1 Sterotype with Priority not ok
5f994ec3f is described below

commit 5f994ec3fe9b1c8e3d71e846f96f8fcf44cbc673
Author: Mark Struberg <[email protected]>
AuthorDate: Thu Jan 26 16:06:35 2023 +0100

    OWB-1417 More than 1 Sterotype with Priority not ok
---
 .../component/creation/ManagedBeanBuilder.java      | 21 +++++++++++++++++++++
 webbeans-tck/standalone-suite.xml                   | 11 +++++++++++
 webbeans-tck/testng-dev.xml                         |  4 ++--
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git 
a/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
 
b/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
index 68ed56916..827fccbb7 100644
--- 
a/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
+++ 
b/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
@@ -18,6 +18,10 @@
  */
 package org.apache.webbeans.component.creation;
 
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import jakarta.annotation.Priority;
 import jakarta.enterprise.inject.UnproxyableResolutionException;
 import jakarta.enterprise.inject.spi.AnnotatedType;
 import jakarta.enterprise.inject.spi.BeanAttributes;
@@ -25,6 +29,7 @@ import jakarta.enterprise.inject.spi.BeanAttributes;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.WebBeansUtil;
 
@@ -64,6 +69,7 @@ public class ManagedBeanBuilder<T, M extends ManagedBean<T>>
     {
         M bean = (M) new ManagedBean<>(webBeansContext, WebBeansType.MANAGED, 
annotatedType, beanAttributes, annotatedType.getJavaClass());
         
bean.setEnabled(webBeansContext.getWebBeansUtil().isBeanEnabled(beanAttributes, 
annotatedType, bean.getStereotypes()));
+        checkStereotypes(bean.getStereotypes());
         
webBeansContext.getWebBeansUtil().checkManagedBeanCondition(annotatedType);
         WebBeansUtil.checkGenericType(annotatedType.getJavaClass(), 
beanAttributes.getScope());
         webBeansContext.getWebBeansUtil().validateBeanInjection(bean);
@@ -75,4 +81,19 @@ public class ManagedBeanBuilder<T, M extends ManagedBean<T>>
         }
         return (M) new UnproxyableBean<>(webBeansContext, 
WebBeansType.MANAGED, beanAttributes, annotatedType, 
annotatedType.getJavaClass(), lazyException);
     }
+
+    private void checkStereotypes(Set<Class<? extends Annotation>> stereotypes)
+    {
+        if (stereotypes != null && stereotypes.size() > 1)
+        {
+            long stereoTypesWithPriority = stereotypes.stream()
+                .filter(s -> s.getAnnotation(Priority.class) != null)
+                .count();
+            if (stereoTypesWithPriority > 1)
+            {
+                throw new WebBeansConfigurationException("More than one 
Stereotype with @Priority on a bean is not allowed!");
+            }
+        }
+
+    }
 }
diff --git a/webbeans-tck/standalone-suite.xml 
b/webbeans-tck/standalone-suite.xml
index 27a876734..28b59f779 100644
--- a/webbeans-tck/standalone-suite.xml
+++ b/webbeans-tck/standalone-suite.xml
@@ -78,6 +78,17 @@
                 </methods>
             </class>
 
+            <!--
+                This is just the most backward breaking change I've seen in 
years.
+                Not going to implement it!
+            -->
+            <class 
name="org.jboss.cdi.tck.tests.deployment.discovery.EmptyBeansXmlDiscoveryTest" >
+                <methods>
+                    <exclude name=".*"/>
+                </methods>
+            </class>
+
+
             <!-- Tests broken in the CDI-2.0 TCK: -->
 
             <!-- https://issues.jboss.org/projects/CDITCK/issues/CDITCK-576 -->
diff --git a/webbeans-tck/testng-dev.xml b/webbeans-tck/testng-dev.xml
index 2ce4ad018..7d0df47e7 100644
--- a/webbeans-tck/testng-dev.xml
+++ b/webbeans-tck/testng-dev.xml
@@ -18,9 +18,9 @@
 <suite name="JSR-346-TCK" verbose="2" configfailurepolicy="continue">
   <test name="JSR-346 TCK">
     <classes>
-          <class 
name="org.jboss.cdi.tck.tests.interceptors.definition.InterceptorDefinitionTest"
 >
+          <class 
name="org.jboss.cdi.tck.tests.definition.stereotype.broken.multiplePriorities.inherited.StereotypeInheritedPriorityConflictTest"
 >
             <methods>
-              <include name="testResolveInterceptorsReturnsOrderedList"/>
+              <include name=".*"/>
             </methods>
           </class>
 

Reply via email to