Register service do not return the id when value of 0.

This commit is contained in:
pengys5 2017-09-08 00:35:25 +08:00
parent ae1b0e3c85
commit 8abad65f6b
2 changed files with 11 additions and 6 deletions

View File

@ -29,8 +29,10 @@ public class ApplicationRegisterServiceHandler extends ApplicationRegisterServic
String applicationCode = applicationCodes.get(i);
int applicationId = applicationIDService.getOrCreate(applicationCode);
KeyWithIntegerValue value = KeyWithIntegerValue.newBuilder().setKey(applicationCode).setValue(applicationId).build();
builder.addApplication(i, value);
if (applicationId != 0) {
KeyWithIntegerValue value = KeyWithIntegerValue.newBuilder().setKey(applicationCode).setValue(applicationId).build();
builder.addApplication(value);
}
}
responseObserver.onNext(builder.build());
responseObserver.onCompleted();

View File

@ -30,10 +30,13 @@ public class ServiceNameDiscoveryServiceHandler extends ServiceNameDiscoveryServ
int applicationId = serviceNameElement.getApplicationId();
String serviceName = serviceNameElement.getServiceName();
int serviceId = serviceNameService.getOrCreate(applicationId, serviceName);
ServiceNameMappingElement.Builder mappingElement = ServiceNameMappingElement.newBuilder();
mappingElement.setServiceId(serviceId);
mappingElement.setElement(serviceNameElement);
builder.addElements(mappingElement);
if (serviceId != 0) {
ServiceNameMappingElement.Builder mappingElement = ServiceNameMappingElement.newBuilder();
mappingElement.setServiceId(serviceId);
mappingElement.setElement(serviceNameElement);
builder.addElements(mappingElement);
}
}
responseObserver.onNext(builder.build());