Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
4a630dc7
Commit
4a630dc7
authored
Nov 11, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only skip ..-prefixed locations when found via wildcard
Closes gh-23983
parent
e8a1c3b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+6
-2
ConfigFileApplicationListenerTests.java
...ot/context/config/ConfigFileApplicationListenerTests.java
+10
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
4a630dc7
...
...
@@ -522,7 +522,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
continue
;
}
if
(
resource
.
isFile
()
&&
hasHiddenPathElement
(
resource
))
{
if
(
resource
.
isFile
()
&&
isPatternLocation
(
location
)
&&
hasHiddenPathElement
(
resource
))
{
if
(
this
.
logger
.
isTraceEnabled
())
{
StringBuilder
description
=
getDescription
(
"Skipped location with hidden path element "
,
location
,
resource
,
profile
);
...
...
@@ -588,7 +588,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
private
Resource
[]
getResources
(
String
location
)
{
try
{
if
(
location
.
contains
(
"*"
))
{
if
(
isPatternLocation
(
location
))
{
return
getResourcesFromPatternLocation
(
location
);
}
return
new
Resource
[]
{
this
.
resourceLoader
.
getResource
(
location
)
};
...
...
@@ -598,6 +598,10 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
}
private
boolean
isPatternLocation
(
String
location
)
{
return
location
.
contains
(
"*"
);
}
private
Resource
[]
getResourcesFromPatternLocation
(
String
location
)
throws
IOException
{
String
directoryPath
=
location
.
substring
(
0
,
location
.
indexOf
(
"*/"
));
Resource
resource
=
this
.
resourceLoader
.
getResource
(
directoryPath
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
View file @
4a630dc7
...
...
@@ -1091,6 +1091,16 @@ class ConfigFileApplicationListenerTests {
assertThat
(
this
.
environment
.
getProperty
(
"fourth.property"
)).
isNull
();
}
@Test
void
nonWildcardHiddenDirectoryLocationShouldNotBeIgnored
()
{
String
location
=
"file:src/test/resources/config/..hidden/"
;
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
"spring.config.location="
+
location
);
this
.
initializer
.
setSearchNames
(
"testproperties"
);
this
.
initializer
.
postProcessEnvironment
(
this
.
environment
,
this
.
application
);
assertThat
(
this
.
environment
.
getProperty
(
"fourth.property"
)).
isNotNull
();
}
@Test
void
locationsWithWildcardDirectoriesShouldLoadAllFilesThatMatch
()
{
String
location
=
"file:src/test/resources/config/*/"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment