Skip to content

Commit

Permalink
fix:修复dubbo3中publishAppMeta中错误设置version (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Mar 1, 2024
1 parent 7f6341a commit e7c5589
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ public class PolarisMetadataReport extends AbstractMetadataReport {

private final ScheduledExecutorService fetchMappingExecutor = Executors.newScheduledThreadPool(4, new NamedThreadFactory("polaris-metadata-report"));

private final String polarisToken;

PolarisMetadataReport(URL url) {
super(url);
this.polarisToken = url.getParameter(Consts.KEY_TOKEN);
this.operator = PolarisOperators.loadOrStoreForMetaReport(url.getHost(), url.getPort(), url.getParameters());
this.config = operator.getPolarisConfig();
this.providerAPI = operator.getProviderAPI();
Expand Down Expand Up @@ -124,7 +127,7 @@ public void publishAppMetadata(SubscriberMetadataIdentifier identifier, Metadata
ReportServiceContractRequest request = new ReportServiceContractRequest();
request.setName(formatAppMetaName(identifier));
request.setService(identifier.getApplication());
request.setVersion(identifier.getRevision());
request.setRevision(identifier.getRevision());
request.setContent(metadataInfo.getContent());
List<InterfaceDescriptor> descriptors = new ArrayList<>(metadataInfo.getServices().size());
metadataInfo.getServices().forEach((s, serviceInfo) -> {
Expand All @@ -145,7 +148,7 @@ public MetadataInfo getAppMetadata(SubscriberMetadataIdentifier identifier, Map<
GetServiceContractRequest request = new GetServiceContractRequest();
request.setName(formatAppMetaName(identifier));
request.setService(identifier.getApplication());
request.setVersion(identifier.getRevision());
request.setVersion("");

Optional<ServiceContractProto.ServiceContract> result = getServiceContract(request);
if (!result.isPresent()) {
Expand Down Expand Up @@ -183,6 +186,7 @@ private ReportServiceContractRequest toDescriptor(MetadataIdentifier identifier,
private Optional<ServiceContractProto.ServiceContract> getServiceContract(GetServiceContractRequest req) {
req.setNamespace(config.getNamespace());
req.setProtocol(Consts.DUBBO_PROTOCOL);
req.setToken(polarisToken);
try {
ServiceRuleResponse response = consumerAPI.getServiceContract(req);
ServiceRule rule = response.getServiceRule();
Expand All @@ -206,6 +210,7 @@ private Optional<ServiceContractProto.ServiceContract> getServiceContract(GetSer
private void reportServiceContract(ReportServiceContractRequest req) {
req.setNamespace(config.getNamespace());
req.setProtocol(Consts.DUBBO_PROTOCOL);
req.setToken(polarisToken);
try {
providerAPI.reportServiceContract(req);
} catch (PolarisException e) {
Expand Down

0 comments on commit e7c5589

Please sign in to comment.