From 66ee9bb1966329d0944825b81aa115b87ed1708c Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 02 Mar 2015 14:47:54 +0000
Subject: [PATCH] Forward port CR-4563 OPENDJ-1574: Allow editing of single-valued InetAddress properties

---
 opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java
index 0eccbcf..f9bae7b 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2013-2014 ForgeRock AS
+ *      Portions Copyright 2013-2015 ForgeRock AS
  */
 package org.forgerock.opendj.config.dsconfig;
 
@@ -1681,13 +1681,18 @@
 
             if (result.isSuccess()) {
                 // Set the new property value(s).
-                Collection<T> newValues = result.getValues();
+                Collection<T> values = result.getValues();
+                // Both newValues and oldValues sets need to use the PropertyDefinition
+                // as their comparator. Constructing a TreeSet<T> directly with the
+                // values collection will fail if the values are e.g. InetAddresses.
+                SortedSet<T> newValues = new TreeSet<T>(d);
+                newValues.addAll(values);
                 SortedSet<T> oldValues = new TreeSet<T>(mo.getPropertyValues(d));
-                mo.setPropertyValues(d, newValues);
+                mo.setPropertyValues(d, values);
 
-                // If there are no newValues when we do a reset.
-                isLastChoiceReset = newValues.isEmpty();
-                registerModification(d, new TreeSet<T>(newValues), oldValues);
+                // If there are no values when we do a reset.
+                isLastChoiceReset = values.isEmpty();
+                registerModification(d, newValues, oldValues);
                 app.println();
                 app.pressReturnToContinue();
                 return MenuResult.success(false);

--
Gitblit v1.10.0