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

Jean-Noël Rouvignac
16.43.2016 108675f4a8f5c17479561333068b9591971dc810
various code cleanups
7 files modified
70 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/ServerConnection.java 2 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/ServerConnectionFactory.java 6 ●●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ProxyBackend.java 2 ●●● patch | view | raw | blame | history
opendj-rest2ldap/pom.xml 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/ReplicaCursor.java 9 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java 14 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/server/changelog/file/LogTest.java 29 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/ServerConnection.java
@@ -34,6 +34,8 @@
 * @param <C>
 *            The type of request context.
 * @see ServerConnectionFactory
 * @deprecated will be removed as part of OPENDJ-3467.
 *             It has been replaced by {@code ReactiveHandler<>}
 */
@Deprecated
public interface ServerConnection<C> extends RequestHandler<C> {
opendj-core/src/main/java/org/forgerock/opendj/ldap/ServerConnectionFactory.java
@@ -30,8 +30,10 @@
 * @param <R>
 *            The type of request context.
 * @see LDAPListener
 * @see Connections#newInternalConnectionFactory(ServerConnectionFactory,
 *      Object) newInternalConnectionFactory
 * @see Connections#newInternalConnectionFactory(ServerConnectionFactory, Object)
 *      newInternalConnectionFactory
 * @deprecated will be removed as part of OPENDJ-3467.
 *             It has been replaced by {@code Function<LDAPClientContext, ReactiveHandler<>>}.
 */
@Deprecated
public interface ServerConnectionFactory<C, R> {
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ProxyBackend.java
@@ -55,7 +55,7 @@
 * proxy authorization. Simple bind requests are performed on a separate
 * connection factory dedicated for authentication.
 * <p>
 * This is implementation is very simple and is only intended as an example:
 * This implementation is very simple and is only intended as an example:
 * <ul>
 * <li>It does not support SSL connections
 * <li>It does not support StartTLS
opendj-rest2ldap/pom.xml
@@ -63,10 +63,10 @@
            <artifactId>i18n-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.forgerock.http</groupId>
            <artifactId>chf-oauth2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.forgerock.http</groupId>
            <artifactId>chf-oauth2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.forgerock.http</groupId>
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/ReplicaCursor.java
@@ -79,8 +79,8 @@
      ReplicaOfflineMsg prevOfflineMsg = this.replicaOfflineMsg.get();
      if (prevOfflineMsg == null || prevOfflineMsg.getCSN().isOlderThan(offlineCSN))
      {
        // Do not spin if the the message for this replica has been changed. Either a newer
        // message has arrived or the next cursor iteration will pick it up.
        // Do not spin if the message for this replica has been changed.
        // Either a newer message has arrived or the next cursor iteration will pick it up.
        this.replicaOfflineMsg.compareAndSet(prevOfflineMsg, new ReplicaOfflineMsg(offlineCSN));
      }
    }
@@ -90,7 +90,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public UpdateMsg getRecord()
  {
@@ -107,7 +106,6 @@
    return replicaId;
  }
  /** {@inheritDoc} */
  @Override
  public boolean next() throws ChangelogException
  {
@@ -148,7 +146,6 @@
        && offlineMsg.getCSN().isOlderThanOrEqualTo(updateMsg.getCSN());
  }
  /** {@inheritDoc} */
  @Override
  public void close()
  {
@@ -156,7 +153,6 @@
    domainDB.unregisterCursor(this);
  }
  /** {@inheritDoc} */
  @Override
  public String toString()
  {
@@ -166,5 +162,4 @@
        + " offlineCSN=" + (msg != null ? msg.getCSN().toStringUI() : null)
        + " cursor=" + cursor.toString().split("", 2)[1];
  }
}
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
@@ -18,12 +18,13 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static java.util.concurrent.TimeUnit.*;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
import static org.forgerock.util.Utils.*;
import static org.forgerock.util.time.Duration.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.INFO_ERROR_READING_SERVER_CONFIGURATION;
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.messages.QuickSetupMessages.INFO_NOT_AVAILABLE_LABEL;
import static org.opends.messages.ToolMessages.*;
@@ -37,7 +38,6 @@
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLException;
@@ -1126,8 +1126,6 @@
    // This connection should always be secure. useSSL = true.
    Connection connection = null;
    final Options options = Options.defaultOptions();
    options.set(CONNECT_TIMEOUT, duration(ci.getConnectTimeout(), TimeUnit.MILLISECONDS));
    LDAPConnectionFactory factory = null;
    while (true)
    {
@@ -1136,9 +1134,11 @@
        final SSLContextBuilder sslBuilder = new SSLContextBuilder();
        sslBuilder.setTrustManager(trustManager == null ? TrustManagers.trustAll() : trustManager);
        sslBuilder.setKeyManager(keyManager);
        options.set(SSL_USE_STARTTLS, ci.useStartTLS());
        options.set(SSL_CONTEXT, sslBuilder.getSSLContext());
        options.set(SSL_ENABLED_PROTOCOLS, ConnectionFactoryProvider.getDefaultProtocols());
        final Options options = Options.defaultOptions()
            .set(CONNECT_TIMEOUT, duration(ci.getConnectTimeout(), MILLISECONDS))
            .set(SSL_USE_STARTTLS, ci.useStartTLS())
            .set(SSL_CONTEXT, sslBuilder.getSSLContext())
            .set(SSL_ENABLED_PROTOCOLS, ConnectionFactoryProvider.getDefaultProtocols());
        factory = new LDAPConnectionFactory(hostName, portNumber, options);
        connection = factory.getConnection();
opendj-server-legacy/src/test/java/org/opends/server/replication/server/changelog/file/LogTest.java
@@ -11,7 +11,7 @@
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2014-2015 ForgeRock AS.
 * Copyright 2014-2016 ForgeRock AS.
 */
package org.opends.server.replication.server.changelog.file;
@@ -22,7 +22,6 @@
import static org.opends.server.replication.server.changelog.file.LogFileTest.*;
import java.io.File;
import java.util.concurrent.atomic.AtomicReference;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
@@ -534,30 +533,4 @@
    assertThat(cursor.next()).isFalse();
    assertThat(cursor.getRecord()).isNull();
  }
  /** Returns a thread that write N records to the provided log. */
  private Thread getWriteLogThread(final Log<String, String> writeLog, final String recordPrefix,
      final AtomicReference<ChangelogException> exceptionRef)
  {
    return new Thread() {
      @Override
      public void run()
      {
        for (int i = 1; i <= 30; i++)
        {
          Record<String, String> record = Record.from(
              String.format("nk%s%03d", recordPrefix, i), "v" + recordPrefix + i);
          try
          {
            writeLog.append(record);
          }
          catch (ChangelogException e)
          {
            // keep the first exception only
            exceptionRef.compareAndSet(null, e);
          }
        }
      }
    };
  }
}