From 90a85f0fed34b0a7d6db93022074a39a17ad27b7 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Fri, 24 Apr 2009 17:05:14 +0000
Subject: [PATCH] Fix for issue where unit tests hang when the startTLS extended operation is used.

---
 opends/src/server/org/opends/server/core/ExtendedOperationBasis.java |   56 +++++++++++---------------------------------------------
 1 files changed, 11 insertions(+), 45 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/ExtendedOperationBasis.java b/opends/src/server/org/opends/server/core/ExtendedOperationBasis.java
index a50bc70..3764c5d 100644
--- a/opends/src/server/org/opends/server/core/ExtendedOperationBasis.java
+++ b/opends/src/server/org/opends/server/core/ExtendedOperationBasis.java
@@ -76,9 +76,6 @@
   // The value for the response associated with this extended operation.
   private ByteString responseValue;
 
-  // Indicates whether a response has yet been sent for this operation.
-  private boolean responseSent;
-
   // The set of response controls for this extended operation.
   private List<Control> responseControls;
 
@@ -119,7 +116,6 @@
     responseValue    = null;
     responseControls = new ArrayList<Control>();
     cancelRequest    = null;
-    responseSent     = false;
 
     if (requestOID.equals(OID_CANCEL_REQUEST))
     {
@@ -524,17 +520,18 @@
       // Stop the processing timer.
       setProcessingStopTime();
 
-      // Send the response to the client, if it has not already been sent.
-      if (! responseSent)
+      // Send the response to the client.
+      if(cancelRequest == null || cancelResult == null ||
+          cancelResult.getResultCode() != ResultCode.CANCELED ||
+          cancelRequest.notifyOriginalRequestor() ||
+          DirectoryServer.notifyAbandonedOperations())
       {
-        responseSent = true;
-        if(cancelRequest == null || cancelResult == null ||
-            cancelResult.getResultCode() != ResultCode.CANCELED ||
-            cancelRequest.notifyOriginalRequestor() ||
-            DirectoryServer.notifyAbandonedOperations())
-        {
-          clientConnection.sendResponse(this);
-        }
+        clientConnection.sendResponse(this);
+      }
+
+      if(requestOID.equals(OID_START_TLS_REQUEST))
+      {
+        clientConnection.finishBindOrStartTLS();
       }
 
       // Log the extended response.
@@ -551,37 +548,6 @@
     }
   }
 
-
-
-  /**
-   * Sends an extended response to the client if none has already been sent.
-   * Note that extended operation handlers are strongly discouraged from using
-   * this method when it is not necessary because its use will prevent the
-   * response from being sent after post-operation plugin processing, which may
-   * impact the result that should be included.  Nevertheless, it may be needed
-   * in some special cases in which the response must be sent before the
-   * extended operation handler completes its processing (e.g., the StartTLS
-   * operation in which the response must be sent in the clear before actually
-   * enabling TLS protection).
-   */
-  public final void sendExtendedResponse()
-  {
-    if (! responseSent)
-    {
-      responseSent = true;
-      clientConnection.sendResponse(this);
-    }
-  }
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public final void setResponseSent()
-  {
-    this.responseSent = true;
-  }
-
   /**
    * {@inheritDoc}
    */

--
Gitblit v1.10.0