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
4b694560
Commit
4b694560
authored
Feb 26, 2021
by
dreis2211
Committed by
Andy Wilkinson
Feb 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore empty prefixes in new PrefixedConfigurationPropertySource
See gh-25445
parent
a8592f36
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
PrefixedConfigurationPropertySource.java
...roperties/source/PrefixedConfigurationPropertySource.java
+4
-1
PrefixedIterableConfigurationPropertySource.java
...s/source/PrefixedIterableConfigurationPropertySource.java
+5
-0
PrefixedIterableConfigurationPropertySourceTests.java
...rce/PrefixedIterableConfigurationPropertySourceTests.java
+11
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/PrefixedConfigurationPropertySource.java
View file @
4b694560
...
...
@@ -47,7 +47,10 @@ class PrefixedConfigurationPropertySource implements ConfigurationPropertySource
}
private
ConfigurationPropertyName
getPrefixedName
(
ConfigurationPropertyName
name
)
{
String
prefix
=
(
StringUtils
.
hasText
(
this
.
prefix
))
?
this
.
prefix
+
"."
:
""
;
if
(!
StringUtils
.
hasText
(
this
.
prefix
))
{
return
name
;
}
String
prefix
=
this
.
prefix
+
"."
;
return
ConfigurationPropertyName
.
of
(
prefix
+
name
);
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/PrefixedIterableConfigurationPropertySource.java
View file @
4b694560
...
...
@@ -18,6 +18,8 @@ package org.springframework.boot.context.properties.source;
import
java.util.stream.Stream
;
import
org.springframework.util.StringUtils
;
/**
* An iterable {@link PrefixedConfigurationPropertySource}.
*
...
...
@@ -32,6 +34,9 @@ class PrefixedIterableConfigurationPropertySource extends PrefixedConfigurationP
@Override
public
Stream
<
ConfigurationPropertyName
>
stream
()
{
if
(!
StringUtils
.
hasText
(
getPrefix
()))
{
return
getSource
().
stream
();
}
ConfigurationPropertyName
prefix
=
ConfigurationPropertyName
.
of
(
getPrefix
());
return
getSource
().
stream
().
map
((
propertyName
)
->
{
if
(
prefix
.
isAncestorOf
(
propertyName
))
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/PrefixedIterableConfigurationPropertySourceTests.java
View file @
4b694560
...
...
@@ -38,4 +38,15 @@ class PrefixedIterableConfigurationPropertySourceTests {
ConfigurationPropertyName
.
of
(
"foo.baz"
),
ConfigurationPropertyName
.
of
(
"hello.bing"
));
}
@Test
void
emptyPrefixShouldReturnOriginalStream
()
{
MockConfigurationPropertySource
source
=
new
MockConfigurationPropertySource
();
source
.
put
(
"my.foo.bar"
,
"bing"
);
source
.
put
(
"my.foo.baz"
,
"biff"
);
source
.
put
(
"hello.bing"
,
"blah"
);
IterableConfigurationPropertySource
prefixed
=
source
.
withPrefix
(
""
);
assertThat
(
prefixed
.
stream
()).
containsExactly
(
ConfigurationPropertyName
.
of
(
"my.foo.bar"
),
ConfigurationPropertyName
.
of
(
"my.foo.baz"
),
ConfigurationPropertyName
.
of
(
"hello.bing"
));
}
}
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