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
eea5d154
Commit
eea5d154
authored
Sep 12, 2019
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
Closes gh-18219
parents
c2023a8c
23174eb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
Bindable.java
...pringframework/boot/context/properties/bind/Bindable.java
+2
-2
BindableTests.java
...framework/boot/context/properties/bind/BindableTests.java
+14
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java
View file @
eea5d154
...
@@ -162,7 +162,7 @@ public final class Bindable<T> {
...
@@ -162,7 +162,7 @@ public final class Bindable<T> {
existingValue
==
null
||
this
.
type
.
isArray
()
||
this
.
boxedType
.
resolve
().
isInstance
(
existingValue
),
existingValue
==
null
||
this
.
type
.
isArray
()
||
this
.
boxedType
.
resolve
().
isInstance
(
existingValue
),
()
->
"ExistingValue must be an instance of "
+
this
.
type
);
()
->
"ExistingValue must be an instance of "
+
this
.
type
);
Supplier
<
T
>
value
=
(
existingValue
!=
null
)
?
()
->
existingValue
:
null
;
Supplier
<
T
>
value
=
(
existingValue
!=
null
)
?
()
->
existingValue
:
null
;
return
new
Bindable
<>(
this
.
type
,
this
.
boxedType
,
value
,
NO_ANNOTATIONS
);
return
new
Bindable
<>(
this
.
type
,
this
.
boxedType
,
value
,
this
.
annotations
);
}
}
/**
/**
...
@@ -171,7 +171,7 @@ public final class Bindable<T> {
...
@@ -171,7 +171,7 @@ public final class Bindable<T> {
* @return an updated {@link Bindable}
* @return an updated {@link Bindable}
*/
*/
public
Bindable
<
T
>
withSuppliedValue
(
Supplier
<
T
>
suppliedValue
)
{
public
Bindable
<
T
>
withSuppliedValue
(
Supplier
<
T
>
suppliedValue
)
{
return
new
Bindable
<>(
this
.
type
,
this
.
boxedType
,
suppliedValue
,
NO_ANNOTATIONS
);
return
new
Bindable
<>(
this
.
type
,
this
.
boxedType
,
suppliedValue
,
this
.
annotations
);
}
}
/**
/**
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BindableTests.java
View file @
eea5d154
...
@@ -160,6 +160,20 @@ class BindableTests {
...
@@ -160,6 +160,20 @@ class BindableTests {
assertThat
(
bindable1
).
isEqualTo
(
bindable3
);
assertThat
(
bindable1
).
isEqualTo
(
bindable3
);
}
}
@Test
// gh-18218
public
void
withExistingValueDoesNotForgetAnnotations
()
{
Annotation
annotation
=
AnnotationUtils
.
synthesizeAnnotation
(
TestAnnotation
.
class
);
Bindable
<?>
bindable
=
Bindable
.
of
(
String
.
class
).
withAnnotations
(
annotation
).
withExistingValue
(
""
);
assertThat
(
bindable
.
getAnnotations
()).
containsExactly
(
annotation
);
}
@Test
// gh-18218
public
void
withSuppliedValueValueDoesNotForgetAnnotations
()
{
Annotation
annotation
=
AnnotationUtils
.
synthesizeAnnotation
(
TestAnnotation
.
class
);
Bindable
<?>
bindable
=
Bindable
.
of
(
String
.
class
).
withAnnotations
(
annotation
).
withSuppliedValue
(()
->
""
);
assertThat
(
bindable
.
getAnnotations
()).
containsExactly
(
annotation
);
}
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@interface
TestAnnotation
{
@interface
TestAnnotation
{
...
...
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