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

Matthew Swift
01.29.2011 6a7fdc04408e52abb5e5cacdc03f51a8e995d5cf
Fix issue OPENDJ-105: Replication protocol error. Bad message type. org.opends.server.replication.protocol.StopMsg received, ReplServerStartMsg required
2 files modified
47 ■■■■■ changed files
opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java 35 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ServerReader.java 12 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
@@ -43,11 +43,7 @@
import org.opends.server.replication.common.RSInfo;
import org.opends.server.replication.common.ServerState;
import org.opends.server.replication.common.ServerStatus;
import org.opends.server.replication.protocol.ProtocolSession;
import org.opends.server.replication.protocol.ProtocolVersion;
import org.opends.server.replication.protocol.ReplServerStartMsg;
import org.opends.server.replication.protocol.ReplicationMsg;
import org.opends.server.replication.protocol.TopologyMsg;
import org.opends.server.replication.protocol.*;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.Attributes;
@@ -195,9 +191,19 @@
      // Reject bad responses
      if (!(msg instanceof ReplServerStartMsg))
      {
        Message message = ERR_REPLICATION_PROTOCOL_MESSAGE_TYPE.get(
            msg.getClass().getCanonicalName(),
            "ReplServerStartMsg");
        Message message;
        if (msg instanceof StopMsg)
        {
          // Remote replication server is probably shutting down.
          message = ERR_RS_DISCONNECTED_DURING_HANDSHAKE.get(
              String.valueOf(getReplicationServerId()),
              session.getReadableRemoteAddress());
        }
        else
        {
          message = ERR_REPLICATION_PROTOCOL_MESSAGE_TYPE.get(msg
              .getClass().getCanonicalName(), "ReplServerStartMsg");
        }
        abortStart(message);
        return;
      }
@@ -495,9 +501,20 @@
    if (!(msg instanceof TopologyMsg))
    {
      Message message = ERR_REPLICATION_PROTOCOL_MESSAGE_TYPE.get(
      Message message;
      if (msg instanceof StopMsg)
      {
        // Remote replication server is probably shutting down.
        message = ERR_RS_DISCONNECTED_DURING_HANDSHAKE.get(
            String.valueOf(getReplicationServerId()),
            session.getReadableRemoteAddress());
      }
      else
      {
        message = ERR_REPLICATION_PROTOCOL_MESSAGE_TYPE.get(
          msg.getClass().getCanonicalName(),
          "TopologyMsg");
      }
      abortStart(message);
    }
opends/src/server/org/opends/server/replication/server/ServerReader.java
@@ -40,7 +40,6 @@
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.replication.common.ServerStatus;
import org.opends.server.replication.protocol.*;
import org.opends.server.types.DebugLogLevel;
/**
 * This class implement the part of the replicationServer that is reading
@@ -222,19 +221,8 @@
          } else if (msg instanceof TopologyMsg)
          {
            TopologyMsg topoMsg = (TopologyMsg) msg;
            try
            {
              ReplicationServerHandler rsh = (ReplicationServerHandler)handler;
              rsh.receiveTopoInfoFromRS(topoMsg);
            }
            catch(Exception e)
            {
              TRACER.debugCaught(DebugLogLevel.ERROR, e);
              errMessage =
                ERR_REPLICATION_PROTOCOL_MESSAGE_TYPE.get(
                    "TopologyMsg", "other");
              logError(errMessage);
            }
          } else if (msg instanceof ChangeStatusMsg)
          {
            ChangeStatusMsg csMsg = (ChangeStatusMsg) msg;