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
07415e16
Commit
07415e16
authored
May 01, 2020
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to fix Windows CI test failure
parent
57179c0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+26
-13
ConfigFileApplicationListenerTests.java
...ot/context/config/ConfigFileApplicationListenerTests.java
+5
-3
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
07415e16
...
...
@@ -520,8 +520,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
continue
;
}
String
name
=
(
location
.
contains
(
"*"
))
?
"applicationConfig: ["
+
resource
.
toString
()
+
"]"
:
"applicationConfig: ["
+
location
+
"]"
;
String
name
=
"applicationConfig: ["
+
getLocationName
(
location
,
resource
)
+
"]"
;
List
<
Document
>
documents
=
loadDocuments
(
loader
,
name
,
resource
);
if
(
CollectionUtils
.
isEmpty
(
documents
))
{
if
(
this
.
logger
.
isTraceEnabled
())
{
...
...
@@ -557,20 +556,20 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
}
private
String
getLocationName
(
String
location
,
Resource
resource
)
{
if
(!
location
.
contains
(
"*"
))
{
return
location
;
}
if
(
resource
instanceof
FileSystemResource
)
{
return
((
FileSystemResource
)
resource
).
getPath
();
}
return
resource
.
getDescription
();
}
private
Resource
[]
getResources
(
String
location
)
{
try
{
if
(
location
.
contains
(
"*"
))
{
String
directoryPath
=
location
.
substring
(
0
,
location
.
indexOf
(
"*/"
));
String
fileName
=
location
.
substring
(
location
.
lastIndexOf
(
"/"
)
+
1
);
Resource
resource
=
this
.
resourceLoader
.
getResource
(
directoryPath
);
File
[]
files
=
resource
.
getFile
().
listFiles
(
File:
:
isDirectory
);
if
(
files
!=
null
)
{
Arrays
.
sort
(
files
,
FILE_COMPARATOR
);
return
Arrays
.
stream
(
files
).
map
((
file
)
->
file
.
listFiles
((
dir
,
name
)
->
name
.
equals
(
fileName
)))
.
filter
(
Objects:
:
nonNull
).
flatMap
((
Function
<
File
[],
Stream
<
File
>>)
Arrays:
:
stream
)
.
map
(
FileSystemResource:
:
new
).
toArray
(
Resource
[]::
new
);
}
return
EMPTY_RESOURCES
;
return
getResourcesFromPatternLocation
(
location
);
}
return
new
Resource
[]
{
this
.
resourceLoader
.
getResource
(
location
)
};
}
...
...
@@ -579,6 +578,20 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
}
private
Resource
[]
getResourcesFromPatternLocation
(
String
location
)
throws
IOException
{
String
directoryPath
=
location
.
substring
(
0
,
location
.
indexOf
(
"*/"
));
String
fileName
=
location
.
substring
(
location
.
lastIndexOf
(
"/"
)
+
1
);
Resource
resource
=
this
.
resourceLoader
.
getResource
(
directoryPath
);
File
[]
files
=
resource
.
getFile
().
listFiles
(
File:
:
isDirectory
);
if
(
files
!=
null
)
{
Arrays
.
sort
(
files
,
FILE_COMPARATOR
);
return
Arrays
.
stream
(
files
).
map
((
file
)
->
file
.
listFiles
((
dir
,
name
)
->
name
.
equals
(
fileName
)))
.
filter
(
Objects:
:
nonNull
).
flatMap
((
Function
<
File
[],
Stream
<
File
>>)
Arrays:
:
stream
)
.
map
(
FileSystemResource:
:
new
).
toArray
(
Resource
[]::
new
);
}
return
EMPTY_RESOURCES
;
}
private
void
addIncludedProfiles
(
Set
<
Profile
>
includeProfiles
)
{
LinkedList
<
Profile
>
existingProfiles
=
new
LinkedList
<>(
this
.
profiles
);
this
.
profiles
.
clear
();
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
View file @
07415e16
...
...
@@ -1085,10 +1085,12 @@ class ConfigFileApplicationListenerTests {
List
<
String
>
sources
=
this
.
environment
.
getPropertySources
().
stream
()
.
filter
((
source
)
->
source
.
getName
().
contains
(
"applicationConfig"
)).
map
((
source
)
->
{
String
name
=
source
.
getName
();
return
name
.
substring
(
name
.
indexOf
(
"src/test/resources"
));
name
=
name
.
substring
(
name
.
indexOf
(
"src/test/resources"
));
name
=
name
.
substring
(
0
,
name
.
length
()
-
1
);
return
name
;
}).
collect
(
Collectors
.
toList
());
assertThat
(
sources
).
containsExactly
(
"src/test/resources/config/1-first/testproperties.properties
]]
"
,
"src/test/resources/config/2-second/testproperties.properties
]]
"
);
assertThat
(
sources
).
containsExactly
(
"src/test/resources/config/1-first/testproperties.properties"
,
"src/test/resources/config/2-second/testproperties.properties"
);
}
@Test
...
...
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