[ 
https://issues.apache.org/jira/browse/ARIES-2059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Raymond Augé updated ARIES-2059:
--------------------------------
    Description: 
Component properties are sometimes merged in the incorrect order.

This was caused by the following misuse of the CDI annotated APIs as follows:

When a repeatable annotation is defined on a class, the API 
{{javax.enterprise.inject.spi.Annotated}} can be misleading because {{<T 
extends Annotation> Set<T> getAnnotations(Class<T> annotationType);}} returns a 
Set.

This means that implementations are free to return annotations not in 
definition order.

Aries CDI mistakenly used this API to retrieve {{@PID}} annotations (which are 
repeatable.)

The work around is pretty simple, when needing to retrieve repeatable 
annotations in definition order pass the container annotationType (all 
repeatable annotations have a container annotation type) to the method instead, 
in this case {{getAnnotations(PIDs.class)}} and then get the {{@PIDs.value()}} 
array which contains the {{@PID}} annotations in definition order.

Note that when there is only a single instance of a repeatable annotation, only 
an instance of the repeatable annotation is used in the class and NOT an 
instance of the container with an array of length 1. This means that you need 
to check first for the container, and then for single instances in order to 
catch all usage scenarios.

  was:
Component properties are sometimes merged in the incorrect order.

This was caused by the following misuse of the CDI annotated APIs as follows:

When a repeatable annotation is defined on a class, the API 
{{javax.enterprise.inject.spi.Annotated}} can be misleading because {{<T 
extends Annotation> Set<T> getAnnotations(Class<T> annotationType);}} returns a 
Set.

This means that implementations are free to return annotations not in 
definition order.

Aries CDI mistakenly used this API to retrieve {{@PID}} annotations (which are 
repeatable.)

The work around is pretty simple, when needing to retrieve repeatable 
annotations in definition order pass the container annotationType (all 
repeatable annotations have a container annotation type) to the method instead, 
in this case {{getAnnotations(PIDs.class)}} and then get the {{@PIDs.value()}} 
array which contains the {{@PID}} annotations in definition order.


> Component properties are sometimes merged in the incorrect order
> ----------------------------------------------------------------
>
>                 Key: ARIES-2059
>                 URL: https://issues.apache.org/jira/browse/ARIES-2059
>             Project: Aries
>          Issue Type: Bug
>          Components: CDI
>            Reporter: Raymond Augé
>            Assignee: Raymond Augé
>            Priority: Major
>             Fix For: cdi-1.1.4
>
>
> Component properties are sometimes merged in the incorrect order.
> This was caused by the following misuse of the CDI annotated APIs as follows:
> When a repeatable annotation is defined on a class, the API 
> {{javax.enterprise.inject.spi.Annotated}} can be misleading because {{<T 
> extends Annotation> Set<T> getAnnotations(Class<T> annotationType);}} returns 
> a Set.
> This means that implementations are free to return annotations not in 
> definition order.
> Aries CDI mistakenly used this API to retrieve {{@PID}} annotations (which 
> are repeatable.)
> The work around is pretty simple, when needing to retrieve repeatable 
> annotations in definition order pass the container annotationType (all 
> repeatable annotations have a container annotation type) to the method 
> instead, in this case {{getAnnotations(PIDs.class)}} and then get the 
> {{@PIDs.value()}} array which contains the {{@PID}} annotations in definition 
> order.
> Note that when there is only a single instance of a repeatable annotation, 
> only an instance of the repeatable annotation is used in the class and NOT an 
> instance of the container with an array of length 1. This means that you need 
> to check first for the container, and then for single instances in order to 
> catch all usage scenarios.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to