From 8cf467249a3cdfdab500aecd7b4dfaadd9f2c1bb Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Tue, 08 Jun 2010 09:28:19 +0000
Subject: [PATCH] Fix issue 4446: allow empty attributes to be added to entries and also add support for empty attributes to LDIFWriter. This was preventing types-only from working in searches.

---
 sdk/src/org/opends/sdk/ldif/LDIFEntryWriter.java |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/sdk/src/org/opends/sdk/ldif/LDIFEntryWriter.java b/sdk/src/org/opends/sdk/ldif/LDIFEntryWriter.java
index 6914a81..273b378 100644
--- a/sdk/src/org/opends/sdk/ldif/LDIFEntryWriter.java
+++ b/sdk/src/org/opends/sdk/ldif/LDIFEntryWriter.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2009-2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.ldif;
@@ -341,9 +341,16 @@
 
       final String attributeDescription = attribute
           .getAttributeDescriptionAsString();
-      for (final ByteString value : attribute)
+      if (attribute.isEmpty())
       {
-        writeKeyAndValue(attributeDescription, value);
+        writeKeyAndValue(attributeDescription, ByteString.empty());
+      }
+      else
+      {
+        for (final ByteString value : attribute)
+        {
+          writeKeyAndValue(attributeDescription, value);
+        }
       }
     }
 

--
Gitblit v1.10.0