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

Jean-Noël Rouvignac
20.21.2016 86afa10ce137d6e7d57b399df7385cea685251c8
Fix NPE in tests

Stacktrace:
org.opends.server.replication.server.ReplicationServerDynamicConfTest#replServerApplyChangeTest
Failure Cause: java.lang.NullPointerException
org.opends.server.replication.server.ReplicationServer.applyConfigurationChange(ReplicationServer.java:879)
org.opends.server.replication.server.ReplicationServerDynamicConfTest.replServerApplyChangeTest(ReplicationServerDynamicConfTest.java:57)
1 files modified
57 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java 57 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
@@ -21,8 +21,20 @@
import static org.opends.server.util.StaticUtils.*;
import java.io.IOException;
import java.net.*;
import java.util.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -30,9 +42,11 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.ConflictBehavior;
import org.forgerock.opendj.server.config.server.ReplicationServerCfg;
import org.forgerock.opendj.server.config.server.UserDefinedVirtualAttributeCfg;
@@ -55,8 +69,6 @@
import org.opends.server.replication.server.changelog.file.ECLEnabledDomainPredicate;
import org.opends.server.replication.server.changelog.file.FileChangelogDB;
import org.opends.server.replication.service.DSRSShutdownSync;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.HostPort;
import org.opends.server.types.SearchFilter;
@@ -82,10 +94,7 @@
  private ReplicationServerCfg config;
  private final DSRSShutdownSync dsrsShutdownSync;
  /**
   * This table is used to store the list of dn for which we are currently
   * handling servers.
   */
  /** This table is used to store the list of dn for which we are currently handling servers. */
  private final Map<DN, ReplicationServerDomain> baseDNs = new HashMap<>();
  /** The database storing the changes. */
@@ -221,8 +230,7 @@
          newSocket.setTcpNoDelay(true);
          newSocket.setKeepAlive(true);
          int timeoutMS = MultimasterReplication.getConnectionTimeoutMS();
          session = replSessionSecurity.createServerSession(newSocket,
              timeoutMS);
          session = replSessionSecurity.createServerSession(newSocket, timeoutMS);
          if (session == null) // Error, go back to accept
          {
            continue;
@@ -704,9 +712,7 @@
    }
  }
  /**
   * Waits for connections to this ReplicationServer.
   */
  /** Waits for connections to this ReplicationServer. */
  void waitConnections()
  {
    // Acquire a domain ticket and wait for a complete cycle of the connect
@@ -745,9 +751,7 @@
    }
  }
  /**
   * Shutdown the Replication Server service and all its connections.
   */
  /** Shutdown the Replication Server service and all its connections. */
  public void shutdown()
  {
    localPorts.remove(getReplicationPort());
@@ -833,7 +837,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      ReplicationServerCfg configuration)
@@ -875,8 +878,11 @@
      stopListen = true;
      try
      {
        listenSocket.close();
        close(listenSocket);
        if (listenThread != null)
        {
        listenThread.join();
        }
        stopListen = false;
        setServerURL();
@@ -950,10 +956,7 @@
     */
    for (HostPort rsAddress : getConfiguredRSAddresses())
    {
      /*
       * No need validate the string format because the admin framework has
       * already done it.
       */
      /* No need validate the string format because the admin framework has already done it. */
      if (rsAddress.getPort() == getReplicationPort()
          && rsAddress.isLocalAddress())
      {
@@ -980,7 +983,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
      ReplicationServerCfg configuration, List<LocalizableMessage> unacceptableReasons)
@@ -1005,7 +1007,6 @@
   * Get the serverId for this replication server.
   *
   * @return The value of the serverId.
   *
   */
  public int getServerId()
  {
@@ -1160,7 +1161,6 @@
   * WARNING : only use this methods for tests purpose.
   *
   * Clear the list of local Replication Servers
   *
   */
  public static void onlyForTestsClearLocalReplicationServerList()
  {
@@ -1337,12 +1337,9 @@
    return MultimasterReplication.isECLEnabled();
  }
  /** {@inheritDoc} */
  @Override
  public String toString()
  {
    return "RS(" + getServerId() + ") on " + serverURL + ", domains="
        + baseDNs.keySet();
    return "RS(" + getServerId() + ") on " + serverURL + ", domains=" + baseDNs.keySet();
  }
}