Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Registry getRegistry(URL url) {
url = url.setPath(RegistryService.class.getName())
.addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName())
.removeParameters(Constants.EXPORT_KEY, Constants.REFER_KEY);
String key = url.toServiceString();
String key = url.toServiceStringWithoutResolving();
// Lock the registry access process to ensure a single instance of the registry
LOCK.lock();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.alibaba.dubbo.registry.NotifyListener;
import com.alibaba.dubbo.registry.Registry;
import com.alibaba.dubbo.registry.RegistryFactory;

import junit.framework.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -87,9 +86,15 @@ public void testRegistryFactoryCache() throws Exception {

@Test
public void testRegistryFactoryIpCache() throws Exception {
Registry registry1 = registryFactory.getRegistry(URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":2233"));
Registry registry2 = registryFactory.getRegistry(URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostAddress() + ":2233"));
Assert.assertEquals(registry1, registry2);
String hostName = NetUtils.getLocalAddress().getHostName();
String ip = NetUtils.getLocalAddress().getHostAddress();
Registry registry1 = registryFactory.getRegistry(URL.valueOf("dubbo://" + hostName + ":2233"));
Registry registry2 = registryFactory.getRegistry(URL.valueOf("dubbo://" + ip + ":2233"));
if (hostName.equals(ip)) {
Assert.assertEquals(registry1, registry2);
} else {
Assert.assertNotSame(registry1, registry2);
}
}

@Test
Expand Down