Skip to content

Commit df9f998

Browse files
CrazyHZMbeiwei30
authored andcommitted
[Dubbo-900] Fix 通过 override 修改 hessian协议的提供者的配置 不生效 #900 (#3363)
* reExport fail fix#900 * modify * use Objects.equals * compare URL for all proxy protocol
1 parent 95fc75a commit df9f998

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProxyProtocol.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.dubbo.rpc.RpcException;
2929

3030
import java.util.List;
31+
import java.util.Objects;
3132
import java.util.concurrent.CopyOnWriteArrayList;
3233

3334
/**
@@ -66,7 +67,10 @@ public <T> Exporter<T> export(final Invoker<T> invoker) throws RpcException {
6667
final String uri = serviceKey(invoker.getUrl());
6768
Exporter<T> exporter = (Exporter<T>) exporterMap.get(uri);
6869
if (exporter != null) {
69-
return exporter;
70+
// When modifying the configuration through override, you need to re-expose the newly modified service.
71+
if (Objects.equals(exporter.getInvoker().getUrl(), invoker.getUrl())) {
72+
return exporter;
73+
}
7074
}
7175
final Runnable runnable = doExport(proxyFactory.getProxy(invoker, true), invoker.getInterface(), invoker.getUrl());
7276
exporter = new AbstractExporter<T>(invoker) {

dubbo-rpc/dubbo-rpc-webservice/src/test/java/org/apache/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.dubbo.common.URL;
2020
import org.apache.dubbo.common.extension.ExtensionLoader;
21+
import org.apache.dubbo.rpc.Exporter;
2122
import org.apache.dubbo.rpc.Protocol;
2223
import org.apache.dubbo.rpc.ProxyFactory;
2324

@@ -37,9 +38,10 @@ public class WebserviceProtocolTest {
3738
@Test
3839
public void testDemoProtocol() throws Exception {
3940
DemoService service = new DemoServiceImpl();
40-
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange")));
41+
Exporter<DemoService> exporter = protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange")));
4142
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange&timeout=3000")));
4243
assertEquals(service.getSize(new String[]{"", "", ""}), 3);
44+
exporter.unexport();
4345
}
4446

4547
@Test

0 commit comments

Comments
 (0)