[ 
https://issues.apache.org/jira/browse/SLING-4178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14214672#comment-14214672
 ] 

Konrad Windszus commented on SLING-4178:
----------------------------------------

This is still the case with the most recent version (2.8.1-SNAPSHOT): 
https://github.com/apache/sling/blob/trunk/bundles/api/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java#L95

> ValueMapDecorator.convertToArray will never return null (even if type 
> conversion does not work)
> -----------------------------------------------------------------------------------------------
>
>                 Key: SLING-4178
>                 URL: https://issues.apache.org/jira/browse/SLING-4178
>             Project: Sling
>          Issue Type: Bug
>          Components: API
>    Affects Versions: API 2.8.0
>            Reporter: Konrad Windszus
>
> Currently the {{ValueMapDecorator}} will never return {{null}} in case type 
> conversion fails and an array type was requested.
> This is neither the case if the underlying map did not contain multiple 
> values (and it was converted a single element array), nor if the underlying 
> array was of a different (incompatible) type.
> For the first case a single element array with value null is returned, for 
> the second case an array is returned which only contains null values (as many 
> as original values).
> I would propose the following change:
> # if array was requested and underlying data is an array: return null instead 
> of array with null items if no item could be converted to the requested array 
> type. 
> # if array was requested and underlying data is an array: only return those 
> items which could be converted to the requested type (leave out the others)
> # if array was requested and underlying data is not an array: return null if 
> value could not be converted to the requested array type.
> This should still be in sync with the behaviour described in SLING-662.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to