You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Stefan Seifert (JIRA)" <ji...@apache.org> on 2017/10/18 12:37:00 UTC
[jira] [Commented] (SLING-7204) OSGi R6 annotations: default value
of an empty array is propagated as null
[ https://issues.apache.org/jira/browse/SLING-7204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16209255#comment-16209255 ]
Stefan Seifert commented on SLING-7204:
---------------------------------------
we are using a class from felix to map the data from service properties to osgi annotations:
{{org.apache.felix.scr.impl.inject.Annotations#toObject}}
we're getting this class from:
{code:xml}
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
<version>2.0.4</version>
<scope>compile</scope>
</dependency>
{code}
so osgi-mock itself is not doing anything for this mapping.
bq. I checked the generated SCR descriptors, and the property is missing. If I add a property to the default value, the property appears in the SCR descriptor.
not sure what you meant here
> OSGi R6 annotations: default value of an empty array is propagated as null
> --------------------------------------------------------------------------
>
> Key: SLING-7204
> URL: https://issues.apache.org/jira/browse/SLING-7204
> Project: Sling
> Issue Type: Bug
> Components: Testing
> Affects Versions: Testing OSGi Mock 2.3.4
> Reporter: Robert Munteanu
>
> I'm conferting some of the Oak code to use the OSGi R6 annotations. I have a config that declares a String[] property which defaults to empty, along the lines of:
> {code:java}
> @Component(configurationPolicy = ConfigurationPolicy.REQUIRE)
> public class CompositeNodeStoreService {
> static @interface Configuration {
>
> /**
> * Writes to these read-only paths won't fail the commit
> */
> String[] ignoreReadOnlyWrites() default {};
> }
> @Activate
> protected void activate(Configuration cfg, ComponentContext context) throws IOException, CommitFailedException {
> ignoreReadOnlyWritePaths = cfg.ignoreReadOnlyWrites()
> {code}
> In a unit test this should default to an empty array, but instead it is null. I checked the generated SCR descriptors, and the property is missing. If I add a property to the default value, the property appears in the SCR descriptor. Maybe a behaviour change in newer revisions of SCR?
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)