This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new 6093addcc5 AttributeDefinition options return null when not present 
(#49)
6093addcc5 is described below

commit 6093addcc535c2d1c38d8d4163b8b01590945d8b
Author: Zymus <[email protected]>
AuthorDate: Tue Oct 18 23:05:02 2022 -0700

    AttributeDefinition options return null when not present (#49)
    
    OSGi Compendium 7.0.0, 105.14.2.18 and 105.14.2.19 specify that if the
    function returns null, there are no option values or labels available.
    
    Currently, these get set to String[0] because the options map.size()
    returns 0.
---
 metatype/src/main/java/org/apache/felix/metatype/AD.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/metatype/src/main/java/org/apache/felix/metatype/AD.java 
b/metatype/src/main/java/org/apache/felix/metatype/AD.java
index a726a20a06..449d40f487 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/AD.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/AD.java
@@ -207,6 +207,12 @@ public class AD extends OptionalAttributes
      */
     public void setOptions(Map options)
     {
+        if (options.size() == 0) {
+            optionLabels = null;
+            optionValues = null;
+            return;
+        }
+
         optionLabels = new String[options.size()];
         optionValues = new String[options.size()];
         int i = 0;

Reply via email to