openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1776383 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanAttributesImpl.java
Date Thu, 29 Dec 2016 07:54:55 GMT
Author: rmannibucau
Date: Thu Dec 29 07:54:54 2016
New Revision: 1776383

URL: http://svn.apache.org/viewvc?rev=1776383&view=rev
Log:
OWB-1164 avoid to duplicate qualifiers when any is already there

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanAttributesImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanAttributesImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanAttributesImpl.java?rev=1776383&r1=1776382&r2=1776383&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanAttributesImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanAttributesImpl.java
Thu Dec 29 07:54:54 2016
@@ -21,7 +21,6 @@ package org.apache.webbeans.component.th
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.component.BeanAttributesImpl;
 
-import javax.enterprise.inject.Any;
 import javax.enterprise.inject.spi.BeanAttributes;
 import java.lang.annotation.Annotation;
 import java.util.Collections;
@@ -31,7 +30,8 @@ import java.util.Set;
 class ThirdpartyBeanAttributesImpl<T> extends BeanAttributesImpl<T>
 {
     private final Set<Annotation> qualifiers;
-    ThirdpartyBeanAttributesImpl(BeanAttributes<T> beanAttributes)
+
+    ThirdpartyBeanAttributesImpl(final BeanAttributes<T> beanAttributes)
     {
         super(beanAttributes, false);
         this.qualifiers = calculateQualifiers(beanAttributes);
@@ -43,24 +43,17 @@ class ThirdpartyBeanAttributesImpl<T> ex
         return qualifiers;
     }
 
-    private Set<Annotation> calculateQualifiers(BeanAttributes<T> beanAttributes)
+    private Set<Annotation> calculateQualifiers(final BeanAttributes<T> beanAttributes)
     {
         final Set<Annotation> originalQualifiers = beanAttributes.getQualifiers() ==
null ?
                 Collections.<Annotation>emptySet() : beanAttributes.getQualifiers();
-        final Set<Annotation> newQualifiers = new HashSet<>(originalQualifiers);
-        boolean foundAny = false;
-        for(Annotation a : originalQualifiers)
-        {
-            if(a instanceof Any)
-            {
-                foundAny = true;
-                break;
-            }
-        }
-        if(!foundAny)
+        if (originalQualifiers.contains(AnyLiteral.INSTANCE))
         {
-            newQualifiers.add(AnyLiteral.INSTANCE);
+            return originalQualifiers;
         }
+
+        final Set<Annotation> newQualifiers = new HashSet<>(originalQualifiers);
+        newQualifiers.add(AnyLiteral.INSTANCE);
         return newQualifiers;
     }
 }



Mime
View raw message