Commit f7f321ca by Jason Song Committed by GitHub

Merge pull request #698 from powerYao/master

use emptyList instead of creating a new list every time.
parents d61803b4 5ad3c0e0
...@@ -9,7 +9,7 @@ import com.netflix.discovery.shared.Application; ...@@ -9,7 +9,7 @@ import com.netflix.discovery.shared.Application;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.Collections;
import java.util.List; import java.util.List;
@Service @Service
...@@ -23,7 +23,7 @@ public class DiscoveryService { ...@@ -23,7 +23,7 @@ public class DiscoveryService {
if (application == null) { if (application == null) {
Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_CONFIGSERVICE); Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_CONFIGSERVICE);
} }
return application != null ? application.getInstances() : new ArrayList<>(); return application != null ? application.getInstances() : Collections.emptyList();
} }
public List<InstanceInfo> getMetaServiceInstances() { public List<InstanceInfo> getMetaServiceInstances() {
...@@ -31,7 +31,7 @@ public class DiscoveryService { ...@@ -31,7 +31,7 @@ public class DiscoveryService {
if (application == null) { if (application == null) {
Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_METASERVICE); Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_METASERVICE);
} }
return application != null ? application.getInstances() : new ArrayList<>(); return application != null ? application.getInstances() : Collections.emptyList();
} }
public List<InstanceInfo> getAdminServiceInstances() { public List<InstanceInfo> getAdminServiceInstances() {
...@@ -39,6 +39,6 @@ public class DiscoveryService { ...@@ -39,6 +39,6 @@ public class DiscoveryService {
if (application == null) { if (application == null) {
Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_ADMINSERVICE); Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_ADMINSERVICE);
} }
return application != null ? application.getInstances() : new ArrayList<>(); return application != null ? application.getInstances() : Collections.emptyList();
} }
} }
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