Disable all filters for internal service (#12515)

* Disable all filters for internal service

* fix uts

* fix uts
This commit is contained in:
Albumen Kevin 2023-06-18 15:12:38 +08:00 committed by GitHub
parent d606e11da5
commit b20d63ef1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 8 deletions

View File

@ -275,6 +275,7 @@ public class InternalServiceConfigBuilder<T> {
serviceConfig.setRef(this.ref);
serviceConfig.setGroup(applicationConfig.getName());
serviceConfig.setVersion("1.0.0");
serviceConfig.setFilter("-default");
serviceConfig.setExecutor(executor);

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.config.integration;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder;
import org.apache.dubbo.rpc.listener.ListenerExporterWrapper;
@ -56,7 +57,13 @@ public abstract class AbstractRegistryCenterExporterListener implements Exporter
@Override
public void exported(Exporter<?> exporter) throws RpcException {
ListenerExporterWrapper listenerExporterWrapper = (ListenerExporterWrapper) exporter;
FilterChainBuilder.CallbackRegistrationInvoker callbackRegistrationInvoker = (FilterChainBuilder.CallbackRegistrationInvoker) listenerExporterWrapper.getInvoker();
Invoker invoker = listenerExporterWrapper.getInvoker();
if (!(invoker instanceof FilterChainBuilder.CallbackRegistrationInvoker)) {
exportedExporters.add(exporter);
return;
}
FilterChainBuilder.CallbackRegistrationInvoker callbackRegistrationInvoker = (FilterChainBuilder.CallbackRegistrationInvoker) invoker;
if (callbackRegistrationInvoker == null ||
callbackRegistrationInvoker.getInterface() != getInterface()) {
return;

View File

@ -188,7 +188,7 @@ class MultipleRegistryCenterExportProviderIntegrationTest implements Integration
// 1. InjvmExporter
// 2. DubboExporter with service-discovery-registry protocol
// 3. DubboExporter with registry protocol
Assertions.assertEquals(exporterListener.getExportedExporters().size(), 5);
Assertions.assertEquals(exporterListener.getExportedExporters().size(), 7);
// The exported exporter contains MultipleRegistryCenterExportProviderFilter
Assertions.assertTrue(exporterListener.getFilters().contains(filter));

View File

@ -156,7 +156,7 @@ class MultipleRegistryCenterInjvmIntegrationTest implements IntegrationTest {
// The MultipleRegistryCenterInjvmService is exported
Assertions.assertTrue(serviceListener.getExportedServices().get(0).isExported());
// The exported exporter is only one
Assertions.assertEquals(exporterListener.getExportedExporters().size(), 1);
Assertions.assertEquals(exporterListener.getExportedExporters().size(), 3);
// The exported exporter contains MultipleRegistryCenterInjvmFilter
Assertions.assertTrue(exporterListener.getFilters().contains(filter));
}
@ -189,4 +189,4 @@ class MultipleRegistryCenterInjvmIntegrationTest implements IntegrationTest {
serviceListener = null;
logger.info(getClass().getSimpleName() + " testcase is ending...");
}
}
}

View File

@ -195,7 +195,7 @@ class SingleRegistryCenterExportProviderIntegrationTest implements IntegrationTe
// 1. InjvmExporter
// 2. DubboExporter with service-discovery-registry protocol
// 3. DubboExporter with registry protocol
Assertions.assertEquals(exporterListener.getExportedExporters().size(), 3);
Assertions.assertEquals(exporterListener.getExportedExporters().size(), 5);
// The exported exporter contains SingleRegistryCenterExportProviderFilter
Assertions.assertTrue(exporterListener.getFilters().contains(filter));
// The consumer can be notified and get provider's metadata through metadata mapping info.
@ -244,4 +244,4 @@ class SingleRegistryCenterExportProviderIntegrationTest implements IntegrationTe
logger.info(getClass().getSimpleName() + " testcase is ending...");
registryProtocolListener = null;
}
}
}

View File

@ -156,7 +156,7 @@ class SingleRegistryCenterInjvmIntegrationTest implements IntegrationTest {
// The SingleRegistryCenterInjvmService is exported
Assertions.assertTrue(serviceListener.getExportedServices().get(0).isExported());
// The exported exporter is only one
Assertions.assertEquals(exporterListener.getExportedExporters().size(), 1);
Assertions.assertEquals(exporterListener.getExportedExporters().size(), 3);
// The exported exporter contains SingleRegistryCenterInjvmFilter
Assertions.assertTrue(exporterListener.getFilters().contains(filter));
}
@ -188,4 +188,4 @@ class SingleRegistryCenterInjvmIntegrationTest implements IntegrationTest {
serviceListener = null;
logger.info(getClass().getSimpleName() + " testcase is ending...");
}
}
}