Skip to content

Commit

Permalink
feat: Uses StringUtils.commaDelimitedListToStringArray instead
Browse files Browse the repository at this point in the history
  • Loading branch information
kworkbee committed Mar 7, 2023
1 parent 3028054 commit 481305c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.cloud.loadbalancer.config;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -37,6 +38,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

/**
* @author Spencer Gibb
Expand All @@ -51,14 +53,12 @@
@ConditionalOnProperty(value = "spring.cloud.loadbalancer.enabled", havingValue = "true", matchIfMissing = true)
public class LoadBalancerAutoConfiguration {

private static final String ZONE_SPLITTER_COMMA = ",";

@Bean
@ConditionalOnMissingBean
public LoadBalancerZoneConfig zoneConfig(Environment environment) {
return new LoadBalancerZoneConfig(environment.getProperty("spring.cloud.loadbalancer.zone"),
List.of(environment.getProperty("spring.cloud.loadbalancer.secondary-zones", "")
.split(ZONE_SPLITTER_COMMA)));
Arrays.stream(StringUtils.commaDelimitedListToStringArray(environment.getProperty("spring.cloud.loadbalancer.secondary-zones", "")))
.toList());
}

@ConditionalOnMissingBean
Expand Down

0 comments on commit 481305c

Please sign in to comment.