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
be837ccb
Commit
be837ccb
authored
Jul 06, 2018
by
dreis2211
Committed by
Stephane Nicoll
Jul 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use PropertySources.stream() where possible
Closes gh-13724
parent
8c691273
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
24 deletions
+14
-24
EnvironmentEndpointDocumentationTests.java
.../documentation/EnvironmentEndpointDocumentationTests.java
+1
-3
CompositePropertySources.java
...ork/boot/context/properties/CompositePropertySources.java
+2
-4
FilteredPropertySources.java
...work/boot/context/properties/FilteredPropertySources.java
+2
-4
ConfigurationPropertySources.java
...ntext/properties/source/ConfigurationPropertySources.java
+3
-4
InvalidConfigurationPropertyValueFailureAnalyzer.java
...zer/InvalidConfigurationPropertyValueFailureAnalyzer.java
+4
-5
SpringApplicationJsonEnvironmentPostProcessor.java
...ot/env/SpringApplicationJsonEnvironmentPostProcessor.java
+2
-4
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/EnvironmentEndpointDocumentationTests.java
View file @
be837ccb
...
...
@@ -22,7 +22,6 @@ import java.util.Map;
import
java.util.Set
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
import
java.util.stream.StreamSupport
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
...
...
@@ -156,8 +155,7 @@ public class EnvironmentEndpointDocumentationTests
@Override
protected
void
customizePropertySources
(
MutablePropertySources
propertySources
)
{
StreamSupport
.
stream
(
environment
.
getPropertySources
().
spliterator
(),
false
)
environment
.
getPropertySources
().
stream
()
.
filter
(
this
::
includedPropertySource
)
.
forEach
(
propertySources:
:
addLast
);
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/CompositePropertySources.java
View file @
be837ccb
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -20,7 +20,6 @@ import java.util.Arrays;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.StreamSupport
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.PropertySources
;
...
...
@@ -42,8 +41,7 @@ final class CompositePropertySources implements PropertySources {
@Override
public
Iterator
<
PropertySource
<?>>
iterator
()
{
return
this
.
propertySources
.
stream
()
.
flatMap
((
sources
)
->
StreamSupport
.
stream
(
sources
.
spliterator
(),
false
))
return
this
.
propertySources
.
stream
().
flatMap
(
PropertySources:
:
stream
)
.
collect
(
Collectors
.
toList
()).
iterator
();
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/FilteredPropertySources.java
View file @
be837ccb
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -20,7 +20,6 @@ import java.util.Arrays;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Set
;
import
java.util.stream.StreamSupport
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.PropertySources
;
...
...
@@ -59,8 +58,7 @@ final class FilteredPropertySources implements PropertySources {
@Override
public
Iterator
<
PropertySource
<?>>
iterator
()
{
return
StreamSupport
.
stream
(
this
.
delegate
.
spliterator
(),
false
)
.
filter
(
this
::
included
).
iterator
();
return
this
.
delegate
.
stream
().
filter
(
this
::
included
).
iterator
();
}
private
boolean
included
(
PropertySource
<?>
propertySource
)
{
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySources.java
View file @
be837ccb
...
...
@@ -18,13 +18,13 @@ package org.springframework.boot.context.properties.source;
import
java.util.Collections
;
import
java.util.stream.Stream
;
import
java.util.stream.StreamSupport
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.MutablePropertySources
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.PropertySource.StubPropertySource
;
import
org.springframework.core.env.PropertySources
;
import
org.springframework.core.env.PropertySourcesPropertyResolver
;
import
org.springframework.util.Assert
;
...
...
@@ -136,9 +136,8 @@ public final class ConfigurationPropertySources {
}
private
static
Stream
<
PropertySource
<?>>
streamPropertySources
(
Iterable
<
PropertySource
<?>>
sources
)
{
return
StreamSupport
.
stream
(
sources
.
spliterator
(),
false
)
.
flatMap
(
ConfigurationPropertySources:
:
flatten
)
PropertySources
sources
)
{
return
sources
.
stream
().
flatMap
(
ConfigurationPropertySources:
:
flatten
)
.
filter
(
ConfigurationPropertySources:
:
isIncluded
);
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java
View file @
be837ccb
...
...
@@ -16,11 +16,9 @@
package
org
.
springframework
.
boot
.
diagnostics
.
analyzer
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
java.util.stream.StreamSupport
;
import
org.springframework.boot.context.properties.source.ConfigurationPropertySources
;
import
org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException
;
...
...
@@ -74,9 +72,10 @@ class InvalidConfigurationPropertyValueFailureAnalyzer
}
private
Stream
<
PropertySource
<?>>
getPropertySources
()
{
Iterable
<
PropertySource
<?>>
sources
=
(
this
.
environment
!=
null
?
this
.
environment
.
getPropertySources
()
:
Collections
.
emptyList
());
return
StreamSupport
.
stream
(
sources
.
spliterator
(),
false
)
if
(
this
.
environment
==
null
)
{
return
Stream
.
empty
();
}
return
this
.
environment
.
getPropertySources
().
stream
()
.
filter
((
source
)
->
!
ConfigurationPropertySources
.
isAttachedConfigurationPropertySource
(
source
));
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java
View file @
be837ccb
...
...
@@ -20,7 +20,6 @@ import java.util.Collection;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.stream.StreamSupport
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
...
...
@@ -92,9 +91,8 @@ public class SpringApplicationJsonEnvironmentPostProcessor
public
void
postProcessEnvironment
(
ConfigurableEnvironment
environment
,
SpringApplication
application
)
{
MutablePropertySources
propertySources
=
environment
.
getPropertySources
();
StreamSupport
.
stream
(
propertySources
.
spliterator
(),
false
)
.
map
(
JsonPropertyValue:
:
get
).
filter
(
Objects:
:
nonNull
).
findFirst
()
.
ifPresent
((
v
)
->
processJson
(
environment
,
v
));
propertySources
.
stream
().
map
(
JsonPropertyValue:
:
get
).
filter
(
Objects:
:
nonNull
)
.
findFirst
().
ifPresent
((
v
)
->
processJson
(
environment
,
v
));
}
private
void
processJson
(
ConfigurableEnvironment
environment
,
...
...
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