Describe the bug spring cloud Greenwich.SR5,spring boot 2.1.12, in windows 10 ,some time config client get cofig form config server none。

**OK Sample ** project directory

D:.
└─workspace
|--└─demo
|--|--└─config-file/
|--|--└─demo-config-server
|--|--└─demo-config-client

before compile mave project,bootstrap.properties file content like

spring.application.name=server-config
spring.application.profiles.active=native,local
spring.cloud.config.server.native.search-locations='file:/${pom.basedir}/../config-file/'
spring.cloud.config.server.bootstrap=true

after compile mave project,target directory bootstrap.properties file content like

spring.application.name=server-config
spring.application.profiles.active=native,local
spring.cloud.config.server.native.search-locations='file:/D:\\workspace\\deme\\demo-config-server/../config-file/'
spring.cloud.config.server.bootstrap=true

**Wrong Sample **

project directory

D:.
└─workspace
|--└─demo
|--|--└─config-file/
|--|--└─base-component
|--|--|--└─demo-config-server
|--|--|--└─demo-config-client

before compile mave project,bootstrap.properties file content like

spring.application.name=server-config
spring.application.profiles.active=native,local
spring.cloud.config.server.native.search-locations='file:/${pom.basedir}/../../config-file/'
spring.cloud.config.server.bootstrap=true

after compile mave project,target directory bootstrap.properties file content like

spring.application.name=server-config
spring.application.profiles.active=native,local
spring.cloud.config.server.native.search-locations='file:/D:\\workspace\\deme\\demo-config-server/../../config-file/'
spring.cloud.config.server.bootstrap=true

I don't know why? but when I moidfy file

org.springframework.cloud.config.server.environment.NativeEnvironmentProperties

code from

public void setSearchLocations(String[] searchLocations) {
        this.searchLocations = searchLocations;
}

to

public void setSearchLocations(String[] searchLocations) {
        String[] tempLocations;
        if (!ArrayUtils.isEmpty(searchLocations)) {
            tempLocations = new String[searchLocations.length];
            for (int i =0;i < searchLocations.length;i++)
            {
                String temp = searchLocations[i];
                tempLocations[i] = temp.replaceAll("\\\\\\\\","/");
            }
        }
        else
        {
            tempLocations = new String[0];
        }
        this.searchLocations = tempLocations;
    }

it will be ok.

I debug the code find

org.springframework.cloud.config.server.environment.NativeEnvironmentRepository

protected Environment clean(Environment value) {
        Environment result = new Environment(value.getName(), value.getProfiles(),
                value.getLabel(), this.version, value.getState());
        for (PropertySource source : value.getPropertySources()) {
            String name = source.getName();
            if (this.environment.getPropertySources().contains(name)) {
                continue;
            }
            name = name.replace("applicationConfig: [", "");
            name = name.replace("]", "");
            if (this.searchLocations != null) {
                boolean matches = false;
                String normal = name;
                if (normal.startsWith("file:")) {
                    normal = StringUtils
                            .cleanPath(new File(normal.substring("file:".length()))
                                    .getAbsolutePath());
                }
                String profile = result.getProfiles() == null ? null
                        : StringUtils.arrayToCommaDelimitedString(result.getProfiles());
                for (String pattern : getLocations(result.getName(), profile,
                        result.getLabel()).getLocations()) {
                    if (!pattern.contains(":")) {
                        pattern = "file:" + pattern;
                    }
                    if (pattern.startsWith("file:")) {
                        pattern = StringUtils
                                .cleanPath(new File(pattern.substring("file:".length()))
                                        .getAbsolutePath())
                                + "/";
                    }
                    if (logger.isTraceEnabled()) {
                        logger.trace("Testing pattern: " + pattern
                                + " with property source: " + name);
                    }

**//in ok sample code will be enter following statement  var mathes will be true.**
**//in wrong sample code will be not enter following statement.**
                    if (normal.startsWith(pattern)
                            && !normal.substring(pattern.length()).contains("/")) {
                        matches = true;
                        break;
                    }
                }
                if (!matches) {
                    // Don't include this one: it wasn't matched by our search locations
                    if (logger.isDebugEnabled()) {
                        logger.debug("Not adding property source: " + name);
                    }
                    continue;
                }
            }
            logger.info("Adding property source: " + name);
            result.add(new PropertySource(name, source.getSource()));
        }
        return result;
    }

I don't konw why,help,thank you!

Comment From: spencergibb

Does using forward slash / help?

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.