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

ian.packer
27.46.2015 25669bf85e5f2bb3f9ba5a6c9c43e149b07095a9
OPENDJ-2327: Improve log messages on certain 'server error' disconnects

Some of these disconnects are seen in the wild more often than the error reporting would suggest was originally expected.

This change adds some better logging when they occur to give users a much clearer idea of where they came from.

With this in place we will be able to audit log files in the future to narrow down if there are any particularly common for exceptions thrown in one of these places. In some cases it might then be worth refining the error messages for those scenarios to make them more user friendly.
3 files modified
44 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPClientConnection.java 12 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPRequestHandler.java 28 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/messages/org/opends/messages/protocol.properties 4 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPClientConnection.java
@@ -985,12 +985,18 @@
        statTracker.updateMessageWritten(message);
      }
    }
    catch (ClosedChannelException e)
    {
      logger.traceException(e);
      disconnect(DisconnectReason.IO_ERROR, false,
          ERR_IO_ERROR_ON_CLIENT_CONNECTION.get(getExceptionMessage(e)));
      return;
    }
    catch (Exception e)
    {
      logger.traceException(e);
      // FIXME -- Log a message or something
      disconnect(DisconnectReason.SERVER_ERROR, false, null);
      disconnect(DisconnectReason.SERVER_ERROR, false,
          ERR_UNEXPECTED_EXCEPTION_ON_CLIENT_CONNECTION.get(getExceptionMessage(e)));
      return;
    }
    finally
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPRequestHandler.java
@@ -289,27 +289,13 @@
              {
                clientConnection = (LDAPClientConnection) key.attachment();
                try
                int readResult = clientConnection.processDataRead();
                if (readResult < 0)
                {
                  int readResult = clientConnection.processDataRead();
                  if (readResult < 0)
                  {
                    key.cancel();
                  }
                  if (readResult > 0) {
                    readyConnections.add(clientConnection);
                  }
                }
                catch (Exception e)
                {
                  logger.traceException(e);
                  // Some other error occurred while we were trying to read data
                  // from the client.
                  // FIXME -- Should we log this?
                  key.cancel();
                  clientConnection.disconnect(DisconnectReason.SERVER_ERROR,
                                              false, null);
                }
                if (readResult > 0) {
                  readyConnections.add(clientConnection);
                }
              }
              catch (Exception e)
@@ -323,8 +309,8 @@
                if (clientConnection != null)
                {
                  clientConnection.disconnect(DisconnectReason.SERVER_ERROR,
                                              false, null);
                  clientConnection.disconnect(DisconnectReason.SERVER_ERROR, false,
                      ERR_UNEXPECTED_EXCEPTION_ON_CLIENT_CONNECTION.get(getExceptionMessage(e)));
                }
              }
            }
opendj-server-legacy/src/messages/org/opends/messages/protocol.properties
@@ -918,4 +918,6 @@
INFO_DISABLE_CONNECTION_1528=Disabling %s
ERR_INITIALIZE_HTTP_CONNECTION_HANDLER_1529=Failed to initialize Http Connection Handler
ERR_TRANSACTION_ID_CONTROL_HAS_NO_VALUE_1530=No value was provided for the transaction \
 id control, whereas an UTF-8 encoded value is expected
 id control, whereas an UTF-8 encoded value is expected
ERR_UNEXPECTED_EXCEPTION_ON_CLIENT_CONNECTION_1531=Exception on the underlying client connection: %s
ERR_IO_ERROR_ON_CLIENT_CONNECTION_1532=The underlying client connection timed out or closed: %s