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
0b19884f
Commit
0b19884f
authored
Dec 03, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unecessary reflection hacks
parent
d9ca0869
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
38 deletions
+3
-38
EnvironmentEndpoint.java
...gframework/boot/actuate/endpoint/EnvironmentEndpoint.java
+2
-19
PropertySourcesPropertyValues.java
...ingframework/boot/bind/PropertySourcesPropertyValues.java
+1
-19
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java
View file @
0b19884f
...
...
@@ -16,12 +16,9 @@
package
org
.
springframework
.
boot
.
actuate
.
endpoint
;
import
java.lang.reflect.Field
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.EnvironmentAware
;
...
...
@@ -32,7 +29,6 @@ import org.springframework.core.env.Environment;
import
org.springframework.core.env.MutablePropertySources
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.util.ReflectionUtils
;
/**
* {@link Endpoint} to expose {@link ConfigurableEnvironment environment} information.
...
...
@@ -98,8 +94,8 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> i
private
void
extract
(
String
root
,
Map
<
String
,
PropertySource
<?>>
map
,
PropertySource
<?>
source
)
{
if
(
source
instanceof
CompositePropertySource
)
{
Set
<
PropertySource
<?>>
nested
=
getNestedPropertySources
((
CompositePropertySource
)
source
);
for
(
PropertySource
<?>
nest
:
nested
)
{
for
(
PropertySource
<?>
nest
:
((
CompositePropertySource
)
source
)
.
getPropertySources
()
)
{
extract
(
source
.
getName
()
+
":"
,
map
,
nest
);
}
}
...
...
@@ -108,19 +104,6 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> i
}
}
@SuppressWarnings
(
"unchecked"
)
private
Set
<
PropertySource
<?>>
getNestedPropertySources
(
CompositePropertySource
source
)
{
try
{
Field
field
=
ReflectionUtils
.
findField
(
CompositePropertySource
.
class
,
"propertySources"
);
field
.
setAccessible
(
true
);
return
(
Set
<
PropertySource
<?>>)
field
.
get
(
source
);
}
catch
(
Exception
ex
)
{
return
Collections
.
emptySet
();
}
}
public
Object
sanitize
(
String
name
,
Object
object
)
{
return
this
.
sanitizer
.
sanitize
(
name
,
object
);
}
...
...
spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java
View file @
0b19884f
...
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
bind
;
import
java.lang.reflect.Field
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
...
...
@@ -32,7 +31,6 @@ import org.springframework.core.env.PropertySource;
import
org.springframework.core.env.PropertySources
;
import
org.springframework.core.env.PropertySourcesPropertyResolver
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.validation.DataBinder
;
/**
...
...
@@ -142,27 +140,11 @@ public class PropertySourcesPropertyValues implements PropertyValues {
private
void
processCompositePropertySource
(
CompositePropertySource
source
,
PropertySourcesPropertyResolver
resolver
,
PropertyNamePatternsMatcher
includes
,
Collection
<
String
>
exacts
)
{
for
(
PropertySource
<?>
nested
:
extractSources
(
source
))
{
for
(
PropertySource
<?>
nested
:
source
.
getPropertySources
(
))
{
processPropertySource
(
nested
,
resolver
,
includes
,
exacts
);
}
}
private
Collection
<
PropertySource
<?>>
extractSources
(
CompositePropertySource
composite
)
{
Field
field
=
ReflectionUtils
.
findField
(
CompositePropertySource
.
class
,
"propertySources"
);
field
.
setAccessible
(
true
);
try
{
@SuppressWarnings
(
"unchecked"
)
Collection
<
PropertySource
<?>>
collection
=
(
Collection
<
PropertySource
<?>>)
field
.
get
(
composite
);
return
collection
;
}
catch
(
Exception
ex
)
{
throw
new
IllegalStateException
(
"Cannot extract property sources from composite"
,
ex
);
}
}
private
void
processDefaultPropertySource
(
PropertySource
<?>
source
,
PropertySourcesPropertyResolver
resolver
,
PropertyNamePatternsMatcher
includes
,
Collection
<
String
>
exacts
)
{
...
...
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