]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.security.core/src/org/argeo/util/naming/AttributesDictionary.java
Improve and simplify OSGi Boot
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / util / naming / AttributesDictionary.java
index a6fddb440804801f81eb01b3ca05283f6099cfd9..c211e8e8a40b0316d230f0d7e68cf34f0a8dfdb9 100644 (file)
@@ -118,9 +118,18 @@ public class AttributesDictionary extends Dictionary<String, Object> {
                                attr.set(i, values[i]);
                        }
                } else {
-                       if (attr.size() != 1)
+                       if (attr.size() > 1)
                                throw new IllegalArgumentException("Attribute " + key + " is multi-valued");
-                       attr.set(0, value.toString());
+                       if (attr.size() == 1) {
+                               try {
+                                       if (!attr.get(0).equals(value))
+                                               attr.set(0, value.toString());
+                               } catch (NamingException e) {
+                                       throw new RuntimeException("Cannot check existing value", e);
+                               }
+                       } else {
+                               attr.add(value.toString());
+                       }
                }
                return oldValue;
        }