Skip to content

Commit f7f321c

Browse files
authored
Merge pull request apolloconfig#698 from powerYao/master
use emptyList instead of creating a new list every time.
2 parents d61803b + 5ad3c0e commit f7f321c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DiscoveryService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.stereotype.Service;
1111

12-
import java.util.ArrayList;
12+
import java.util.Collections;
1313
import java.util.List;
1414

1515
@Service
@@ -23,22 +23,22 @@ public List<InstanceInfo> getConfigServiceInstances() {
2323
if (application == null) {
2424
Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_CONFIGSERVICE);
2525
}
26-
return application != null ? application.getInstances() : new ArrayList<>();
26+
return application != null ? application.getInstances() : Collections.emptyList();
2727
}
2828

2929
public List<InstanceInfo> getMetaServiceInstances() {
3030
Application application = eurekaClient.getApplication(ServiceNameConsts.APOLLO_METASERVICE);
3131
if (application == null) {
3232
Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_METASERVICE);
3333
}
34-
return application != null ? application.getInstances() : new ArrayList<>();
34+
return application != null ? application.getInstances() : Collections.emptyList();
3535
}
3636

3737
public List<InstanceInfo> getAdminServiceInstances() {
3838
Application application = eurekaClient.getApplication(ServiceNameConsts.APOLLO_ADMINSERVICE);
3939
if (application == null) {
4040
Tracer.logEvent("Apollo.EurekaDiscovery.NotFound", ServiceNameConsts.APOLLO_ADMINSERVICE);
4141
}
42-
return application != null ? application.getInstances() : new ArrayList<>();
42+
return application != null ? application.getInstances() : Collections.emptyList();
4343
}
4444
}

0 commit comments

Comments
 (0)