Commit 35db3822 by lepdou

fix service locator bug

parent 6f611a78
......@@ -41,18 +41,18 @@ public class ServiceLocator {
public ServiceDTO getAdminService(Env env) throws ServiceException {
List<ServiceDTO> services = getServices(env, "admin");
if (services.size() == 0) {
if (services == null || services.size() == 0) {
throw new ServiceException("No available admin service");
}
return services.get(adminCallCounts.getAndIncrement() % services.size());
return services.get(Math.abs(adminCallCounts.getAndIncrement()) % services.size());
}
public ServiceDTO getConfigService(Env env) throws ServiceException {
List<ServiceDTO> services = getServices(env, "config");
if (services.size() == 0) {
if (services == null || services.size() == 0) {
throw new ServiceException("No available config service");
}
return services.get(configCallCounts.getAndIncrement() % services.size());
return services.get(Math.abs(configCallCounts.getAndIncrement()) % services.size());
}
private List<ServiceDTO> getServices(Env env, String serviceUrl) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment