Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanyuan2021 committed Jan 22, 2024
1 parent 1b8f024 commit 7c1ffc9
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
*/
public class BizDubboBootstrapListener implements ApplicationListener {

private final DubboBootstrap dubboBootstrap;
private final DubboBootstrap dubboBootstrap;

private final ConfigManager configManager;
private final ServiceRepository serviceRepository;

private final ConfigManager configManager;
private final ServiceRepository serviceRepository;
// private final Environment environment;

public BizDubboBootstrapListener() {
Expand Down Expand Up @@ -75,13 +76,15 @@ private void onContextRefreshedEvent(ContextRefreshedEvent event) {

private void onContextClosedEvent(ContextClosedEvent event) {
// DubboBootstrap.unexportServices 会 unexport 所有服务,只需要 unexport 当前 biz 的服务即可
Map<String, ServiceConfigBase<?>> exportedServices = ReflectionUtils.getField(dubboBootstrap, DubboBootstrap.class, "exportedServices");
Map<String, ServiceConfigBase<?>> exportedServices = ReflectionUtils.getField(
dubboBootstrap, DubboBootstrap.class, "exportedServices");

Set<String> bizUnexportServices = new HashSet<>();
for (Map.Entry<String, ServiceConfigBase<?>> entry : exportedServices.entrySet()) {
String serviceKey = entry.getKey();
ServiceConfigBase<?> sc = entry.getValue();
if (sc.getRef().getClass().getClassLoader() == Thread.currentThread().getContextClassLoader()) {
if (sc.getRef().getClass().getClassLoader() == Thread.currentThread()
.getContextClassLoader()) {
bizUnexportServices.add(serviceKey);
configManager.removeConfig(sc);
sc.unexport();
Expand Down

0 comments on commit 7c1ffc9

Please sign in to comment.