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

Alexander Klimetschek updated FELIX-2835:
-----------------------------------------

    Description: 
A property with options should use the key=value parameters after the "options" 
parameter as name=label for the metatype options:

    @scr.property type="String" value="one" options one="One" two="Two" 
three="Three"

However, it produces this single option:

            <Option value="one=One" label="three=Three"/>

The problem is that this loop in 
org.apache.felix.scrplugin.helper.PropertyHandler.processProperty() [0] is 
inherently broken due to both a "j++" in the for loop and a "j += 2" at the 
end, and a parameters[j+2]:

            for (int j=0; j < parameters.length; j++) {
                if (Constants.PROPERTY_OPTIONS.equals(parameters[j])) {
                    options = new LinkedHashMap<String, String>();
                } else if (options != null) {
                    String optionLabel = parameters[j];
                    String optionValue = (j < parameters.length-2) ? 
parameters[j+2] : null;
                    if (optionValue != null) {
                        options.put(optionLabel, optionValue);
                    }
                    j += 2;
                }
            }

Without having debugged it, I guess it should be parameters[j+1] and j+=1, as 
you only skip one parameter for reading the label, not two (given that 
one="One" is represented as two parameters "one" and "One").

[0] 
http://svn.apache.org/repos/asf/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/PropertyHandler.java

  was:
A property with options should use the key=value parameters after the "options" 
parameter as name=label for the metatype options:

    @scr.property type="String" value="one" options one="One" two="Two" 
three="Three"

However, it produces this single option:

            <Option value="one=One" label="three=Three"/>

The problem is that this loop is inherently broken due to both a "j++" in the 
for loop and a "j += 2" at the end, and a parameters[j+2]:

            for (int j=0; j < parameters.length; j++) {
                if (Constants.PROPERTY_OPTIONS.equals(parameters[j])) {
                    options = new LinkedHashMap<String, String>();
                } else if (options != null) {
                    String optionLabel = parameters[j];
                    String optionValue = (j < parameters.length-2) ? 
parameters[j+2] : null;
                    if (optionValue != null) {
                        options.put(optionLabel, optionValue);
                    }
                    j += 2;
                }
            }

Without having debugged it, I guess it should be parameters[j+1] and j+=1, as 
you only skip one parameter for reading the label, not two (given that 
one="One" is represented as two parameters "one" and "One").


> SCR plugin: Parsing of "options" for property tag broken for javadoc 
> annotations
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-2835
>                 URL: https://issues.apache.org/jira/browse/FELIX-2835
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  scr-1.6.0
>            Reporter: Alexander Klimetschek
>
> A property with options should use the key=value parameters after the 
> "options" parameter as name=label for the metatype options:
>     @scr.property type="String" value="one" options one="One" two="Two" 
> three="Three"
> However, it produces this single option:
>             <Option value="one=One" label="three=Three"/>
> The problem is that this loop in 
> org.apache.felix.scrplugin.helper.PropertyHandler.processProperty() [0] is 
> inherently broken due to both a "j++" in the for loop and a "j += 2" at the 
> end, and a parameters[j+2]:
>             for (int j=0; j < parameters.length; j++) {
>                 if (Constants.PROPERTY_OPTIONS.equals(parameters[j])) {
>                     options = new LinkedHashMap<String, String>();
>                 } else if (options != null) {
>                     String optionLabel = parameters[j];
>                     String optionValue = (j < parameters.length-2) ? 
> parameters[j+2] : null;
>                     if (optionValue != null) {
>                         options.put(optionLabel, optionValue);
>                     }
>                     j += 2;
>                 }
>             }
> Without having debugged it, I guess it should be parameters[j+1] and j+=1, as 
> you only skip one parameter for reading the label, not two (given that 
> one="One" is represented as two parameters "one" and "One").
> [0] 
> http://svn.apache.org/repos/asf/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/PropertyHandler.java

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to