From 9ee3d32dd459650afff9678e49d2535962333862 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 27 Aug 2009 15:38:26 +0000
Subject: [PATCH] Fix for issue 4195 (dsreplication enable should check that the user did not provide the same host:port twice) The fix also applies to dsreplication initialize.

---
 opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index 7dedabc..d3ddd58 100644
--- a/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -2267,11 +2267,29 @@
         hostDestination = ci.getHostName();
         portDestination = ci.getPortNumber();
 
-        ctxDestination = createInitialLdapContextInteracting(ci);
-
-        if (ctxDestination == null)
+        boolean error = false;
+        if (hostSource.equalsIgnoreCase(hostDestination))
         {
-          cancelled = true;
+          if (portSource == portDestination)
+          {
+            portDestination = -1;
+            Message message = ERR_REPLICATION_INITIALIZE_SAME_SERVER_PORT.get(
+                hostSource, String.valueOf(portSource));
+            println();
+            println(message);
+            println();
+            error = true;
+          }
+        }
+
+        if (!error)
+        {
+          ctxDestination = createInitialLdapContextInteracting(ci);
+
+          if (ctxDestination == null)
+          {
+            cancelled = true;
+          }
         }
       }
       catch (ClientException ce)

--
Gitblit v1.10.0