Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix referenceBean initialization issue #2719

Merged
merged 1 commit into from
Nov 1, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ private T createProxy(Map<String, String> map) {
c = true; // default true
}
if (c && !invoker.isAvailable()) {
// make it possible for consumer to retry later if provider is temporarily unavailable
initialized = false;
throw new IllegalStateException("Failed to check the status of the service " + interfaceName + ". No provider available for the service " + (group == null ? "" : group + "/") + interfaceName + (version == null ? "" : ":" + version) + " from the url " + invoker.getUrl() + " to the consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion());
}
if (logger.isInfoEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,45 @@ public void testInjvm() throws Exception {
demoService.unexport();
}
}

}
/**
* unit test for dubbo-1765
*/
@Test
public void testReferenceRetry() {
ApplicationConfig application = new ApplicationConfig();
application.setName("test-reference-retry");
RegistryConfig registry = new RegistryConfig();
registry.setAddress("multicast://224.5.6.7:1234");
ProtocolConfig protocol = new ProtocolConfig();
protocol.setName("dubbo");
ReferenceConfig<DemoService> rc = new ReferenceConfig<DemoService>();
rc.setApplication(application);
rc.setRegistry(registry);
rc.setInterface(DemoService.class.getName());
boolean success = false;
DemoService demoService = null;
try {
demoService = rc.get();
success = true;
} catch (Exception e) {
e.printStackTrace();
}
Assert.assertFalse(success);
Assert.assertNull(demoService);
ServiceConfig<DemoService> sc = new ServiceConfig<DemoService>();
sc.setInterface(DemoService.class);
sc.setRef(new DemoServiceImpl());
sc.setApplication(application);
sc.setRegistry(registry);
sc.setProtocol(protocol);
try {
sc.export();
demoService = rc.get();
success = true;
} catch (Exception e) {
e.printStackTrace();
}
Assert.assertTrue(success);
Assert.assertNotNull(demoService);
}
}