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

Prashant
8 hours ago 17f7f07e9af3c481f345df913157191eac3a7d8d
Close LDAP listener channels that fail to bind (#1316)

Close the channel in the catch block. The close helper ignores null,
which covers a failure in ServerSocketChannel.open() itself.
1 files modified
5 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPConnectionHandler.java 5 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
@@ -1038,20 +1038,23 @@
    int numRegistered = 0;
    for (InetAddress a : listenAddresses)
    {
      ServerSocketChannel channel = null;
      try
      {
        ServerSocketChannel channel = ServerSocketChannel.open();
        channel = ServerSocketChannel.open();
        channel.socket().setReuseAddress(allowReuseAddress);
        channel.socket()
            .bind(new InetSocketAddress(a, listenPort), backlog);
        channel.configureBlocking(false);
        channel.register(selector, SelectionKey.OP_ACCEPT);
        channel = null;
        numRegistered++;
        logger.info(NOTE_CONNHANDLER_STARTED_LISTENING, handlerName);
      }
      catch (Exception e)
      {
        close(channel);
        logger.traceException(e);
        logger.error(ERR_LDAP_CONNHANDLER_CREATE_CHANNEL_FAILED, currentConfig.dn(), a.getHostAddress(), listenPort,