From 371634acb4f2cbf59b5fdca7f694cd8936fd30a3 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 07 Nov 2006 22:53:06 +0000
Subject: [PATCH] Update the LDAP request handler to provide a mechanism that attempts to detect whether the JVM is susceptible to the issue described in CR 6322825 in which calls to the NIO select() method fail.  If this problem is detected, a detailed error message will be written to the log and the LDAP connection handler will not be started.

---
 opends/src/server/org/opends/server/protocols/ldap/LDAPRequestHandler.java |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPRequestHandler.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPRequestHandler.java
index 76d3c54..587a975 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPRequestHandler.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPRequestHandler.java
@@ -28,6 +28,7 @@
 
 
 
+import java.io.IOException;
 import java.nio.channels.CancelledKeyException;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
@@ -137,6 +138,30 @@
       String message = getMessage(msgID, handlerName, String.valueOf(e));
       throw new InitializationException(msgID, message, e);
     }
+
+    try
+    {
+      // Check to see if we get an error while trying to perform a select.  If
+      // we do, then it's likely CR 6322825 and the server won't be able to
+      // handle LDAP requests in its current state.
+      selector.selectNow();
+    }
+    catch (IOException ioe)
+    {
+      StackTraceElement[] stackElements = ioe.getStackTrace();
+      if ((stackElements != null) && (stackElements.length > 0))
+      {
+        StackTraceElement ste = stackElements[0];
+        if (ste.getClassName().equals("sun.nio.ch.DevPollArrayWrapper") &&
+            (ste.getMethodName().indexOf("poll") >= 0) &&
+            ioe.getMessage().equalsIgnoreCase("Invalid argument"))
+        {
+          int    msgID   = MSGID_LDAP_REQHANDLER_DETECTED_JVM_ISSUE_CR6322825;
+          String message = getMessage(msgID, String.valueOf(ioe));
+          throw new InitializationException(msgID, message, ioe);
+        }
+      }
+    }
   }
 
 

--
Gitblit v1.10.0