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
0f105f74
Commit
0f105f74
authored
Jul 18, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail fast if spring.config.location uses unknown file extension
Closes gh-17241
parent
572a436d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+2
-0
ConfigFileApplicationListenerTests.java
...ot/context/config/ConfigFileApplicationListenerTests.java
+11
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
0f105f74
...
...
@@ -453,6 +453,8 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
return
;
}
}
throw
new
IllegalStateException
(
"File extension of config file location '"
+
location
+
"' is not known to any PropertySourceLoader"
);
}
Set
<
String
>
processed
=
new
HashSet
<>();
for
(
PropertySourceLoader
loader
:
this
.
propertySourceLoaders
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
View file @
0f105f74
...
...
@@ -65,6 +65,7 @@ import org.springframework.test.util.ReflectionTestUtils;
import
org.springframework.util.StringUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalStateException
;
/**
* Tests for {@link ConfigFileApplicationListener}.
...
...
@@ -981,6 +982,16 @@ class ConfigFileApplicationListenerTests {
assertThat
(
this
.
environment
.
getProperty
(
"gh17001loaded"
)).
isEqualTo
(
"true"
);
}
@Test
void
whenConfigLocationSpecifiesUnknownFileExtensionConfigFileProcessingFailsFast
()
{
String
location
=
"classpath:application.unknown"
;
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
"spring.config.location="
+
location
);
assertThatIllegalStateException
()
.
isThrownBy
(()
->
this
.
initializer
.
postProcessEnvironment
(
this
.
environment
,
this
.
application
))
.
withMessageContaining
(
location
);
}
private
Condition
<
ConfigurableEnvironment
>
matchingPropertySource
(
final
String
sourceName
)
{
return
new
Condition
<
ConfigurableEnvironment
>(
"environment containing property source "
+
sourceName
)
{
...
...
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