From 05d5d2e61edfcd1302f837fd679f80305a44e170 Mon Sep 17 00:00:00 2001 From: chainHo Date: Tue, 12 Jan 2021 06:33:39 +0800 Subject: [PATCH] remove redundanct default search location (#1716) compare two arrays, use `Arrays.equals` , otherwise the default will add into locations twice. --- .../cloud/config/server/support/AbstractScmAccessor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AbstractScmAccessor.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AbstractScmAccessor.java index 8e279c7e..aae8163a 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AbstractScmAccessor.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AbstractScmAccessor.java @@ -21,10 +21,12 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -217,7 +219,7 @@ public abstract class AbstractScmAccessor implements ResourceLoaderAware { if (locations == null || locations.length == 0) { locations = AbstractScmAccessorProperties.DEFAULT_LOCATIONS; } - else if (locations != AbstractScmAccessorProperties.DEFAULT_LOCATIONS) { + else if (!Arrays.equals(locations, AbstractScmAccessorProperties.DEFAULT_LOCATIONS)) { locations = StringUtils.concatenateStringArrays(AbstractScmAccessorProperties.DEFAULT_LOCATIONS, locations); } Collection output = new LinkedHashSet();