refactor: 使用 getFirst 优化首元素访问
This commit is contained in:
+1
-1
@@ -59,7 +59,7 @@ public class SnailJobConfig {
|
||||
if (StringUtils.isNotBlank(serverName)) {
|
||||
List<ServiceInstance> instances = discoveryClient.getInstances(serverName);
|
||||
if (CollUtil.isNotEmpty(instances)) {
|
||||
ServiceInstance instance = instances.get(0);
|
||||
ServiceInstance instance = instances.getFirst();
|
||||
System.setProperty("snail-job.server.host", instance.getHost());
|
||||
System.setProperty("snail-job.server.port", properties.getPort());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user