Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Use the host returned by the Server when connecting to it

Shai Ereraa9874685006b
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java b/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java
index 2de42ad33ea..f62140804de 100755
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java
@@ -17,7 +17,6 @@ package org.apache.lucene.replicator;
* limitations under the License.
*/
-import java.net.SocketException;
import java.util.Random;
import org.apache.http.conn.ClientConnectionManager;
@@ -125,12 +124,14 @@ public abstract class ReplicatorTestCase extends LuceneTestCase {
return server;
}
- /**
- * Returns a {@link Server}'s port. This method assumes that no
- * {@link Connector}s were added to the Server besides the default one.
- */
- public static int serverPort(Server httpServer) {
- return httpServer.getConnectors()[0].getLocalPort();
+ /** Returns a {@link Server}'s port. */
+ public static int serverPort(Server server) {
+ return server.getConnectors()[0].getLocalPort();
+ }
+
+ /** Returns a {@link Server}'s host. */
+ public static String serverHost(Server server) {
+ return server.getConnectors()[0].getHost();
}
/**
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java b/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
index 9ba289d8c3b..46b59424fb0 100755
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
@@ -50,6 +50,7 @@ public class HttpReplicatorTest extends ReplicatorTestCase {
private DirectoryReader reader;
private Server server;
private int port;
+ private String host;
private Directory serverIndexDir, handlerIndexDir;
private void startServer() throws Exception {
@@ -59,6 +60,7 @@ public class HttpReplicatorTest extends ReplicatorTestCase {
replicationHandler.addServletWithMapping(servlet, ReplicationService.REPLICATION_CONTEXT + "/*");
server = newHttpServer(replicationHandler);
port = serverPort(server);
+ host = serverHost(server);
}
@Before
@@ -103,7 +105,7 @@ public class HttpReplicatorTest extends ReplicatorTestCase {
@Test
public void testBasic() throws Exception {
- Replicator replicator = new HttpReplicator("127.0.0.1", port, ReplicationService.REPLICATION_CONTEXT + "/s1",
+ Replicator replicator = new HttpReplicator(host, port, ReplicationService.REPLICATION_CONTEXT + "/s1",
getClientConnectionManager());
ReplicationClient client = new ReplicationClient(replicator, new IndexReplicationHandler(handlerIndexDir, null),
new PerSessionDirectoryFactory(clientWorkDir));