[
https://issues.apache.org/jira/browse/SLING-3674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14033769#comment-14033769
]
Konrad Windszus edited comment on SLING-3674 at 6/17/14 1:19 PM:
-----------------------------------------------------------------
[~justinedelson] Wouldn't it be good to use
https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/ClassUtils.html#primitivesToWrappers%28java.lang.Class[]%29
was (Author: kwin):
[~justinedelson] Wouldn't it be good to use
https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/ClassUtils.html#primitivesToWrappers%28java.lang.Class[]%29?
> Array of wrappers to primitives conversion in Sling Models
> ----------------------------------------------------------
>
> Key: SLING-3674
> URL: https://issues.apache.org/jira/browse/SLING-3674
> Project: Sling
> Issue Type: Bug
> Components: Extensions
> Affects Versions: Sling Models Implementation 1.0.4
> Reporter: Krystian Panek
> Assignee: Justin Edelson
> Labels: models
> Fix For: Sling Models Implementation 1.0.6
>
> Attachments: ArrayPrimitivesModel.java, ResourceModelClassesTest.java
>
>
> Problem is related with: https://issues.apache.org/jira/browse/SLING-3547
> Suppose that I have:
> {quote}
> @Inject
> private int[] scores;
> @Inject
> private Integer[] scores;
> {quote}
> For first declaration injection does not work, because in my environment
> ValueMap contains array of wrapped integers and type cast to array of
> primitives cannot be done. I noticed an exception:
> {quote}
> 27 [main] ERROR org.apache.sling.models.impl.ModelAdapterFactory - unable to
> create object
> java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
> at
> org.apache.sling.api.wrappers.ValueMapDecorator.convertToArray(ValueMapDecorator.java:100)
> {quote}
> Second declaration seems to work but how to apply default value for it?
> According to Sling Models documentation, example with default value for array
> of integers currently it is not possible to get it working. Same error as for
> first declaration.
> I wrote unit test for it. I hope, useful for reproducing problem, see
> attachments.
--
This message was sent by Atlassian JIRA
(v6.2#6252)