From 27dc85f53cea91141c3350ea653663ddc8dc27d2 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Wed, 15 Apr 2009 21:34:44 +0000
Subject: [PATCH] Fix for issue 3918: Restored prior behavior where an empty controls context-specific BER sequence is not encoded if the LDAP message have no controls.

---
 opends/src/server/org/opends/server/protocols/ldap/LDAPMessage.java |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPMessage.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPMessage.java
index 7aefadb..13f8a87 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPMessage.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPMessage.java
@@ -546,12 +546,15 @@
     stream.writeInteger(messageID);
     protocolOp.write(stream);
 
-    stream.writeStartSequence(TYPE_CONTROL_SEQUENCE);
-    for(Control control : controls)
+    if(!controls.isEmpty())
     {
-      control.write(stream);
+      stream.writeStartSequence(TYPE_CONTROL_SEQUENCE);
+      for(Control control : controls)
+      {
+        control.write(stream);
+      }
+      stream.writeEndSequence();
     }
-    stream.writeEndSequence();
 
     stream.writeEndSequence();
   }

--
Gitblit v1.10.0