From 18672390e7b0ac4d26be050cd3461e21c6a94183 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 26 Mar 2015 15:25:02 +0000
Subject: [PATCH] Follow up on r11861: CR-5578 fix OPENDJ-821: org.opends.server.protocols.jmx.client-unknown

---
 opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java |   46 +++++++++++++++++++++-------------------------
 1 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java b/opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java
index 3c78b82..5beb2c1 100644
--- a/opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java
+++ b/opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/protocols/jmx/OpendsRmiServerSocketFactory.java
@@ -31,33 +31,30 @@
 import java.net.ServerSocket;
 import java.rmi.server.RMIServerSocketFactory;
 
-
 /**
+ * An implementation of the socketServer.
+ * <p>
  * The RMI connector class starts and stops the JMX RMI connector server.
  * There are 2 different connector servers
  * <ul>
- * <li> the RMI Client connector server, supporting TLS-encrypted.
- * communication, server authentication by certificate and client
+ * <li>the RMI Client connector server, supporting TLS-encrypted communication,
+ * server authentication by certificate and client
  * authentication by providing appropriate LDAP credentials through
- * SASL/PLAIN.
- * <li> the RMI client connector server, supporting TLS-encrypted
- * communication, server authentication by certificate, client
- * authentication by certificate and identity assertion through SASL/PLAIN.
+ * SASL/PLAIN.</li>
+ * <li>the RMI client connector server, supporting TLS-encrypted communication,
+ * server authentication by certificate, client
+ * authentication by certificate and identity assertion through SASL/PLAIN.</li>
  * </ul>
  * <p>
  * Each connector is registered into the JMX MBean server.
  */
-
-/**
- * An implementation of the socketServer.
- */
 public class OpendsRmiServerSocketFactory implements RMIServerSocketFactory
 {
   /** The address to listen on, which could be INADDR_ANY. */
   private final InetAddress listenAddress;
 
-  /** The Created ServerSocket. */
-  ServerSocket serverSocket;
+  /** The created ServerSocket. */
+  private ServerSocket serverSocket;
 
   /**
    * Create a new socket factory which will listen on the specified address.
@@ -69,17 +66,12 @@
     this.listenAddress = listenAddress;
   }
 
-  /**
-   *  Create a server socket on the specified port, listening on the address
-   *  passed in the constructor. (port 0 indicates an anonymous port).
-   *
-   *  @param port the port number
-   *  @return the server socket on the specified port
-   *  @throws IOException if an I/O error occurs during server socket creation
-   */
-  public ServerSocket createServerSocket(int port)  throws IOException
+  /** {@inheritDoc} */
+  @Override
+  public ServerSocket createServerSocket(int port) throws IOException
   {
-    return new ServerSocket(port, 100, listenAddress);
+    serverSocket = new ServerSocket(port, 50, listenAddress);
+    return serverSocket;
   }
 
   /**
@@ -87,8 +79,12 @@
    *
    * @throws IOException If an I/O error occurs when closing the socket.
    */
-  protected void close() throws IOException
+  void close() throws IOException
   {
-    serverSocket.close();
+    if (serverSocket != null)
+    {
+      serverSocket.close();
+      serverSocket = null;
+    }
   }
 }

--
Gitblit v1.10.0