Source:
<code>private Optional<SingularityLoadBalancerUpdate> syncUpstreamsForServiceHelper(SingularityRequest singularityRequest, SingularityDeploy deploy, Optional<String> loadBalancerUpstreamGroup) { try { LOG.trace("Sending load balancer request to sync upstreams for service {}.", singularityRequest.getId()); final LoadBalancerRequestId loadBalancerRequestId = new LoadBalancerRequestId(String.format("%s-%s-%s", singularityRequest.getId(), deploy.getId(), System.currentTimeMillis()), LoadBalancerRequestType.REMOVE, Optional.absent()); Collection<UpstreamInfo> upstreamsInLoadBalancerForService = getLoadBalancerUpstreamsForService(singularityRequest.getId(), loadBalancerUpstreamGroup); LOG.trace("Upstreams in load balancer for service are {}.", singularityRequest.getId(), upstreamsInLoadBalancerForService); Collection<UpstreamInfo> upstreamsInSingularityForService = getUpstreamsFromActiveTasksForService(singularityRequest.getId(), loadBalancerUpstreamGroup); LOG.trace("Upstreams in singularity for service are {}.", singularityRequest.getId(), upstreamsInSingularityForService); final List<UpstreamInfo> extraUpstreams = getExtraUpstreamsInLoadBalancer(upstreamsInLoadBalancerForService, upstreamsInSingularityForService); <START> if (extraUpstreams.size() == 0) { <END> LOG.trace("No extra upstreams for service {}. No load balancer request sent.", singularityRequest.getId()); return Optional.absent(); } LOG.info("Syncing upstreams for service {}. Making and sending load balancer request to remove extra upstreams. The upstreams removed are: {}.", singularityRequest.getId(), loadBalancerRequestId, extraUpstreams.size(), extraUpstreams); return Optional.of(lbClient.makeAndSendLoadBalancerRequest(loadBalancerRequestId, Collections.emptyList(), extraUpstreams, deploy, singularityRequest)); } catch (TaskIdNotFoundException e) { LOG.error("TaskId not found for requestId: {}.", singularityRequest.getId()); return Optional.absent(); } }</code><technical_language>another nitpick note, List<T> isEmpty() size == 0</technical_language>

Target:
private Optional<SingularityLoadBalancerUpdate> syncUpstreamsForServiceHelper(SingularityRequest singularityRequest, SingularityDeploy deploy, Optional<String> loadBalancerUpstreamGroup) { try { LOG.debug("Sending load balancer request to sync upstreams for service {}.", singularityRequest.getId()); Collection<UpstreamInfo> upstreamsInLoadBalancerForService = getLoadBalancerUpstreamsForService(singularityRequest.getId(), deploy.getLoadBalancerServiceIdOverride(), loadBalancerUpstreamGroup); LOG.debug("Upstreams in load balancer for singularity service are {}.", singularityRequest.getId(), upstreamsInLoadBalancerForService); Collection<UpstreamInfo> upstreamsInSingularityForService = getUpstreamsFromActiveHealthyAndCleaningTasksForService(singularityRequest.getId(), loadBalancerUpstreamGroup); LOG.debug("Upstreams in singularity for service are {}.", singularityRequest.getId(), upstreamsInSingularityForService); final List<UpstreamInfo> extraUpstreams = getExtraUpstreamsInLoadBalancer(upstreamsInLoadBalancerForService, upstreamsInSingularityForService); if (extraUpstreams.isEmpty()) { LOG.debug("No extra upstreams for service {}. No load balancer request sent.", singularityRequest.getId()); return Optional.absent(); } final LoadBalancerRequestId loadBalancerRequestId = new LoadBalancerRequestId(String.format("%s-%s-%s", singularityRequest.getId(), deploy.getId(), System.currentTimeMillis()), LoadBalancerRequestType.REMOVE, Optional.absent()); LOG.info("Syncing upstreams for service {}. Making and sending load balancer request to remove extra upstreams. The upstreams removed are: {}.", singularityRequest.getId(), loadBalancerRequestId, extraUpstreams.size(), extraUpstreams); return Optional.of(lbClient.makeAndSendLoadBalancerRequest(loadBalancerRequestId, Collections.emptyList(), extraUpstreams, deploy, singularityRequest)); } catch (TaskIdNotFoundException e) { LOG.error("TaskId not found for requestId: {}.", singularityRequest.getId()); return Optional.absent(); } }