From 93962e064794511b2ab9980c88e143424251a9f2 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 09 Jan 2014 14:20:58 +0000
Subject: [PATCH] Frontport fix for OPENDJ-1269.

---
 opendj3-server-dev/src/server/org/opends/server/protocols/jmx/JmxConnectionHandler.java |   62 +++++++++---------------------
 1 files changed, 19 insertions(+), 43 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/jmx/JmxConnectionHandler.java b/opendj3-server-dev/src/server/org/opends/server/protocols/jmx/JmxConnectionHandler.java
index dadaa6a..8da12b9 100644
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/jmx/JmxConnectionHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/protocols/jmx/JmxConnectionHandler.java
@@ -22,19 +22,19 @@
  *
  *
  *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions copyright 2013 ForgeRock AS
+ *      Portions copyright 2013-2014 ForgeRock AS
  */
 package org.opends.server.protocols.jmx;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.*;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.opends.messages.Message;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.std.server.ConnectionHandlerCfg;
 import org.opends.server.admin.std.server.JMXConnectionHandlerCfg;
-import org.opends.server.api.AlertGenerator;
 import org.opends.server.api.ClientConnection;
 import org.opends.server.api.ConnectionHandler;
 import org.opends.server.api.ServerShutdownListener;
@@ -57,12 +57,12 @@
  */
 public final class JmxConnectionHandler extends
     ConnectionHandler<JMXConnectionHandlerCfg> implements
-    ServerShutdownListener, AlertGenerator,
+    ServerShutdownListener,
     ConfigurationChangeListener<JMXConnectionHandlerCfg> {
 
   /**
    * Key that may be placed into a JMX connection environment map to
-   * provide a custom <code>javax.net.ssl.TrustManager</code> array
+   * provide a custom {@code javax.net.ssl.TrustManager} array
    * for a connection.
    */
   public static final String TRUST_MANAGER_ARRAY_KEY =
@@ -73,7 +73,7 @@
     "org.opends.server.protocols.jmx.JMXConnectionHandler";
 
   /** The list of active client connection. */
-  private List<ClientConnection> connectionList;
+  private final List<ClientConnection> connectionList;
 
   /** The current configuration state. */
   private JMXConnectionHandlerCfg currentConfig;
@@ -88,7 +88,7 @@
   private String protocol;
 
   /** The set of listeners for this connection handler. */
-  private List<HostPort> listeners = new LinkedList<HostPort>();
+  private final List<HostPort> listeners = new LinkedList<HostPort>();
 
   /**
    * Creates a new instance of this JMX connection handler. It must be
@@ -97,7 +97,7 @@
   public JmxConnectionHandler() {
     super("JMX Connection Handler Thread");
 
-    this.connectionList = new LinkedList<ClientConnection>();
+    this.connectionList = new CopyOnWriteArrayList<ClientConnection>();
   }
 
 
@@ -110,7 +110,7 @@
       JMXConnectionHandlerCfg config) {
     // Create variables to include in the response.
     ResultCode resultCode = ResultCode.SUCCESS;
-    List<Message> messages = new ArrayList<Message>();
+    final List<Message> messages = new ArrayList<Message>();
 
     // Determine whether or not the RMI connection needs restarting.
     boolean rmiConnectorRestart = false;
@@ -193,40 +193,6 @@
   }
 
 
-
-  /**
-   * Retrieves information about the set of alerts that this generator
-   * may produce. The map returned should be between the notification
-   * type for a particular notification and the human-readable
-   * description for that notification. This alert generator must not
-   * generate any alerts with types that are not contained in this
-   * list.
-   *
-   * @return Information about the set of alerts that this generator
-   *         may produce.
-   */
-  @Override
-  public Map<String, String> getAlerts()
-  {
-    return new LinkedHashMap<String, String>();
-  }
-
-
-
-  /**
-   * Retrieves the fully-qualified name of the Java class for this
-   * alert generator implementation.
-   *
-   * @return The fully-qualified name of the Java class for this alert
-   *         generator implementation.
-   */
-  @Override
-  public String getClassName() {
-    return CLASS_NAME;
-  }
-
-
-
   /**
    * Retrieves the set of active client connections that have been
    * established through this connection handler.
@@ -335,7 +301,7 @@
     // Configuration is ok.
     currentConfig = config;
 
-    List<Message> reasons = new LinkedList<Message>();
+    final List<Message> reasons = new LinkedList<Message>();
     if (!isPortConfigurationAcceptable(String.valueOf(config.dn()),
         config.getListenPort(), reasons))
     {
@@ -497,6 +463,16 @@
   }
 
 
+  /**
+   * Unregisters a client connection from this JMX connection handler.
+   *
+   * @param connection
+   *          The client connection.
+   */
+  public void unregisterClientConnection(ClientConnection connection) {
+    connectionList.remove(connection);
+  }
+
 
   /**
    * {@inheritDoc}

--
Gitblit v1.10.0