Skip to content

Commit

Permalink
修复 bug:当dubbo接口注册为服务别称时,consumer端找不到可用 provider
Browse files Browse the repository at this point in the history
  • Loading branch information
amyson authored and wuyh committed Jul 28, 2023
1 parent 0b1d33c commit d8d2c88
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,13 @@ public void run() {
}

private void onInstances(URL url, NotifyListener listener, Instance[] instances) {
String requireInterface = url.getServiceInterface();
LOGGER.info("[POLARIS] update instances count: {}, service: {}", null == instances ? 0 : instances.length,
url.getServiceInterface());
requireInterface);
List<URL> urls = new ArrayList<>();
if (null != instances) {
for (Instance instance : instances) {
urls.add(instanceToURL(instance));
urls.add(instanceToURL(requireInterface, instance));
}
}
URL routerURL = buildRouterURL(url);
Expand All @@ -246,9 +247,10 @@ private void onInstances(URL url, NotifyListener listener, Instance[] instances)
PolarisRegistry.this.notify(url, listener, urls);
}

private static URL instanceToURL(Instance instance) {
private static URL instanceToURL(String requireInterface, Instance instance) {
Map<String, String> newMetadata = new HashMap<>(instance.getMetadata());
boolean hasWeight = false;
newMetadata.put("interface", requireInterface);
if (newMetadata.containsKey(Constants.WEIGHT_KEY)) {
String weightStr = newMetadata.get(Constants.WEIGHT_KEY);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

package com.tencent.polaris.dubbox.router.example.api;

public class FooRequest {
import java.io.Serializable;

public class FooRequest implements Serializable {

private String user;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

package com.tencent.polaris.dubbox.router.example.api;

public class FooResponse {
import java.io.Serializable;

public class FooResponse implements Serializable {

private String message;

Expand Down
2 changes: 1 addition & 1 deletion dubbox/dubbox-examples/dubbox-router-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</dependency>
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-router-polaris</artifactId>
<artifactId>dubbox-router-polaris</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down

0 comments on commit d8d2c88

Please sign in to comment.