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

gbellato
19.03.2009 e0e37d25213b6659461d679845e593bbd2d572c1
 fix for 3829 : "Severe Error" logged when dsreplication enable is used with "localhost" and hostname for --host1 and --host2

In such cases the Replication Server were not detecting that they are already connected
and was keeping trying to open new connection to each other Replication Server.

The trick is simply to handle loopback and localhost addresses as equals.
1 files modified
21 ■■■■■ changed files
opends/src/server/org/opends/server/replication/server/ReplicationServer.java 21 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -309,10 +309,29 @@
          {
            InetAddress inetAddress = InetAddress.getByName(hostname);
            String serverAddress = inetAddress.getHostAddress() + ":" + port;
            String alternServerAddress = null;
            if (hostname.equalsIgnoreCase("localhost"))
            {
              // if "localhost" was used as the hostname in the configuration
              // also check is the connection is already opened with the
              // local address.
              alternServerAddress =
                InetAddress.getLocalHost().getHostAddress() + ":" + port;
            }
            if (inetAddress.equals(InetAddress.getLocalHost()))
            {
              // if the host address is the local one, also check
              // if the connection is already opened with the "localhost"
              // address
              alternServerAddress = "127.0.0.1" + ":" + port;
            }
            if ((serverAddress.compareTo("127.0.0.1:" + replicationPort) != 0)
                && (serverAddress.compareTo(this.localURL) != 0)
                && (!connectedReplServers.contains(serverAddress)))
                && (!connectedReplServers.contains(serverAddress)
                && ((alternServerAddress == null)
                    || !connectedReplServers.contains(alternServerAddress))))
            {
              this.connect(serverURL, replicationServerDomain.getBaseDn());
            }