You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by yi...@apache.org on 2018/08/01 02:27:52 UTC
[incubator-dubbo] branch master updated: fix referenceBean
initialization issue (#1999)
This is an automated email from the ASF dual-hosted git repository.
yiji pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new adafee0 fix referenceBean initialization issue (#1999)
adafee0 is described below
commit adafee02ca2c9adf370d92a12fb3c8b4b60bca77
Author: ATAKing1023 <an...@qq.com>
AuthorDate: Wed Aug 1 10:27:49 2018 +0800
fix referenceBean initialization issue (#1999)
---
.../org/apache/dubbo/config/ReferenceConfig.java | 2 +
.../apache/dubbo/config/ReferenceConfigTest.java | 45 ++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
index da86ea0..7901c78 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
@@ -422,6 +422,8 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
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()) {
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
index 1bac760..c8cb048 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
@@ -59,5 +59,50 @@ public class ReferenceConfigTest {
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);
+
+ }
}
\ No newline at end of file