mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

neil_a_wilson
07.53.2006 371634acb4f2cbf59b5fdca7f694cd8936fd30a3
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 Issue Number: 860
2 files modified
48 ■■■■■ changed files
opends/src/server/org/opends/server/messages/ProtocolMessages.java 23 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/protocols/ldap/LDAPRequestHandler.java 25 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/messages/ProtocolMessages.java
@@ -4199,6 +4199,17 @@
  /**
   * The message ID for the message that will be used if the server detects that
   * the underlying JVM suffers from the issue described in CR 6322825.  This
   * takes a single argument, which is a string representation of the exception
   * that was caught.
   */
  public static final int MSGID_LDAP_REQHANDLER_DETECTED_JVM_ISSUE_CR6322825 =
       CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_FATAL_ERROR | 387;
  /**
   * Associates a set of generic messages with the message IDs defined in this
   * class.
   */
@@ -5447,6 +5458,18 @@
                    "%s was unable to open a selector to multiplex reads " +
                    "from clients:  %s.  This request handler cannot " +
                    "continue processing.");
    registerMessage(MSGID_LDAP_REQHANDLER_DETECTED_JVM_ISSUE_CR6322825,
                    "Unable to call select() in the LDAP connection " +
                    "handler:  %s.  It appears that your JVM may be " +
                    "susceptible to the issue described at " +
                    "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=" +
                    "6322825, and it is unable to handle LDAP requests in " +
                    "its current configuration.  Please upgrade to a newer " +
                    "JVM that does not exhibit this behavior (Java 5.0 " +
                    "Update 8 or higher) or set the number of available " +
                    "file descriptors to a value greater than or equal to " +
                    "8193 (e.g., by issuing the command 'ulimit -n 8193') " +
                    "before starting the Directory Server.");
    registerMessage(MSGID_LDAP_REQHANDLER_CANNOT_REGISTER,
                    "%s was unable to register this client connection with " +
                    "the selector:  %s.");
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);
        }
      }
    }
  }