diff --git a/polaris-sync-registry-plugins/registry-consul/src/main/java/cn/polarismesh/polaris/sync/registry/plugins/consul/ConsulRegistryCenter.java b/polaris-sync-registry-plugins/registry-consul/src/main/java/cn/polarismesh/polaris/sync/registry/plugins/consul/ConsulRegistryCenter.java index 0e1471f..64fd7e3 100644 --- a/polaris-sync-registry-plugins/registry-consul/src/main/java/cn/polarismesh/polaris/sync/registry/plugins/consul/ConsulRegistryCenter.java +++ b/polaris-sync-registry-plugins/registry-consul/src/main/java/cn/polarismesh/polaris/sync/registry/plugins/consul/ConsulRegistryCenter.java @@ -200,9 +200,11 @@ private List convertConsulInstance(Service service, List filters = (null == group ? null : group.getMetadataMap()); for (HealthService healthService : instances) { + LOG.info("[Consul]convert instance {}", healthService); HealthService.Service instance = healthService.getService(); Map metadata = instance.getMeta(); boolean matched = CommonUtils.matchMetadata(metadata, filters); + LOG.info("[Consul]convert instance {}, matched {}", healthService, matched); if (!matched) { continue; } @@ -211,7 +213,9 @@ private List convertConsulInstance(Service service, List convertNacosInstances(Service service, List< builder.setNamespace(ResponseUtils.toStringValue(service.getNamespace())); builder.setService(ResponseUtils.toStringValue(service.getService())); builder.setWeight(ResponseUtils.toUInt32Value((int) weight)); - builder.putAllMetadata(CommonUtils.defaultMap(metadata)); + if (!CollectionUtils.isEmpty(metadata)) { + builder.putAllMetadata(metadata); + } builder.setHost(ResponseUtils.toStringValue(ip)); builder.setPort(ResponseUtils.toUInt32Value(port)); builder.setIsolate(ResponseUtils.toBooleanValue(!enabled)); diff --git a/polaris-sync-registry-plugins/registry-polaris/src/main/java/cn/polarismesh/polaris/sync/registry/plugins/polaris/PolarisRegistryCenter.java b/polaris-sync-registry-plugins/registry-polaris/src/main/java/cn/polarismesh/polaris/sync/registry/plugins/polaris/PolarisRegistryCenter.java index 6f985ed..05c1304 100644 --- a/polaris-sync-registry-plugins/registry-polaris/src/main/java/cn/polarismesh/polaris/sync/registry/plugins/polaris/PolarisRegistryCenter.java +++ b/polaris-sync-registry-plugins/registry-polaris/src/main/java/cn/polarismesh/polaris/sync/registry/plugins/polaris/PolarisRegistryCenter.java @@ -197,7 +197,9 @@ private List convertPolarisInstances(com.tencent.polaris. ServiceProto.Instance.Builder builder = ServiceProto.Instance.newBuilder(); builder.setId(ResponseUtils.toStringValue(instanceId)); builder.setWeight(ResponseUtils.toUInt32Value(instance.getWeight())); - builder.putAllMetadata(CommonUtils.defaultMap(metadata)); + if (CollectionUtils.isEmpty(metadata)) { + builder.putAllMetadata(metadata); + } builder.setHost(ResponseUtils.toStringValue(ip)); builder.setPort(ResponseUtils.toUInt32Value(port)); builder.setIsolate(ResponseUtils.toBooleanValue(instance.isIsolated()));