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
4b1e5e9c
Commit
4b1e5e9c
authored
Apr 04, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve diagnostics when loading a property source from a file fails
Closes gh-8294
parent
43f34546
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+16
-10
No files found.
spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
4b1e5e9c
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -208,12 +208,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
...
@@ -208,12 +208,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
protected
void
addPropertySources
(
ConfigurableEnvironment
environment
,
protected
void
addPropertySources
(
ConfigurableEnvironment
environment
,
ResourceLoader
resourceLoader
)
{
ResourceLoader
resourceLoader
)
{
RandomValuePropertySource
.
addToEnvironment
(
environment
);
RandomValuePropertySource
.
addToEnvironment
(
environment
);
try
{
new
Loader
(
environment
,
resourceLoader
).
load
();
new
Loader
(
environment
,
resourceLoader
).
load
();
}
catch
(
IOException
ex
)
{
throw
new
IllegalStateException
(
"Unable to load configuration files"
,
ex
);
}
}
}
/**
/**
...
@@ -339,7 +334,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
...
@@ -339,7 +334,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
:
resourceLoader
;
:
resourceLoader
;
}
}
public
void
load
()
throws
IOException
{
public
void
load
()
{
this
.
propertiesLoader
=
new
PropertySourcesLoader
();
this
.
propertiesLoader
=
new
PropertySourcesLoader
();
this
.
activatedProfiles
=
false
;
this
.
activatedProfiles
=
false
;
this
.
profiles
=
Collections
.
asLifoQueue
(
new
LinkedList
<
Profile
>());
this
.
profiles
=
Collections
.
asLifoQueue
(
new
LinkedList
<
Profile
>());
...
@@ -423,8 +418,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
...
@@ -423,8 +418,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
return
unprocessedActiveProfiles
;
return
unprocessedActiveProfiles
;
}
}
private
void
load
(
String
location
,
String
name
,
Profile
profile
)
private
void
load
(
String
location
,
String
name
,
Profile
profile
)
{
throws
IOException
{
String
group
=
"profile="
+
(
profile
==
null
?
""
:
profile
);
String
group
=
"profile="
+
(
profile
==
null
?
""
:
profile
);
if
(!
StringUtils
.
hasText
(
name
))
{
if
(!
StringUtils
.
hasText
(
name
))
{
// Try to load directly from the location
// Try to load directly from the location
...
@@ -456,6 +450,18 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
...
@@ -456,6 +450,18 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
}
private
PropertySource
<?>
loadIntoGroup
(
String
identifier
,
String
location
,
private
PropertySource
<?>
loadIntoGroup
(
String
identifier
,
String
location
,
Profile
profile
)
{
try
{
return
doLoadIntoGroup
(
identifier
,
location
,
profile
);
}
catch
(
Exception
ex
)
{
throw
new
IllegalStateException
(
"Failed to load property source from location '"
+
location
+
"'"
,
ex
);
}
}
private
PropertySource
<?>
doLoadIntoGroup
(
String
identifier
,
String
location
,
Profile
profile
)
throws
IOException
{
Profile
profile
)
throws
IOException
{
Resource
resource
=
this
.
resourceLoader
.
getResource
(
location
);
Resource
resource
=
this
.
resourceLoader
.
getResource
(
location
);
PropertySource
<?>
propertySource
=
null
;
PropertySource
<?>
propertySource
=
null
;
...
...
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