Skip to content

Commit

Permalink
load the first zone detector
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj committed Mar 19, 2024
1 parent d5c484a commit c627b92
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
Expand All @@ -32,6 +33,7 @@
import org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import static org.apache.dubbo.common.constants.CommonConstants.PREFERRED_KEY;
Expand Down Expand Up @@ -60,6 +62,12 @@ public ZoneAwareClusterInvoker(Directory<T> directory) {
if (loader.hasExtension("default")) {
zoneDetector = loader.getExtension("default");
}
if (zoneDetector == null) {
Set<ZoneDetector> zoneDetectors = loader.getSupportedExtensionInstances();
if (CollectionUtils.isNotEmpty(zoneDetectors)) {
zoneDetector = zoneDetectors.iterator().next();
}
}
}

@Override
Expand Down

0 comments on commit c627b92

Please sign in to comment.