mirror of https://github.com/apache/lucene.git
SOLR-5567: ZkController getHostAddress duplicates url prefix
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1553491 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
35b159f14c
commit
ca4acb2bb7
|
@ -213,6 +213,9 @@ Bug Fixes
|
|||
|
||||
* SOLR-5562: ConcurrentUpdateSolrServer constructor ignores supplied httpclient.
|
||||
(Kyle Halliday via Mark Miller)
|
||||
|
||||
* SOLR-5567: ZkController getHostAddress duplicates url prefix.
|
||||
(Kyle Halliday, Alexey Serba, shalin)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
|
|
@ -477,10 +477,7 @@ public final class ZkController {
|
|||
host = "http://" + hostaddress;
|
||||
} else {
|
||||
Matcher m = URL_PREFIX.matcher(host);
|
||||
if (m.matches()) {
|
||||
String prefix = m.group(1);
|
||||
host = prefix + host;
|
||||
} else {
|
||||
if (!m.matches()) {
|
||||
host = "http://" + host;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,11 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@Slow
|
||||
public class ZkControllerTest extends SolrTestCaseJ4 {
|
||||
|
@ -255,6 +257,46 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHostName() throws Exception {
|
||||
String zkDir = dataDir.getAbsolutePath() + File.separator
|
||||
+ "zookeeper/server1/data";
|
||||
CoreContainer cc = null;
|
||||
|
||||
ZkTestServer server = new ZkTestServer(zkDir);
|
||||
try {
|
||||
server.run();
|
||||
|
||||
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
|
||||
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
|
||||
|
||||
cc = getCoreContainer();
|
||||
ZkController zkController = null;
|
||||
|
||||
try {
|
||||
zkController = new ZkController(cc, server.getZkAddress(), TIMEOUT, 10000,
|
||||
"http://127.0.0.1", "8983", "solr", 0, true, new CurrentCoreDescriptorProvider() {
|
||||
|
||||
@Override
|
||||
public List<CoreDescriptor> getCurrentDescriptors() {
|
||||
// do nothing
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (IllegalArgumentException e) {
|
||||
fail("ZkController did not normalize host name correctly");
|
||||
} finally {
|
||||
if (zkController != null)
|
||||
zkController.close();
|
||||
}
|
||||
} finally {
|
||||
if (cc != null) {
|
||||
cc.shutdown();
|
||||
}
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private CoreContainer getCoreContainer() {
|
||||
CoreContainer cc = new CoreContainer(solrHomeDirectory.getAbsolutePath());
|
||||
cc.load();
|
||||
|
|
Loading…
Reference in New Issue