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
f24c92c6
Commit
f24c92c6
authored
Feb 02, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workaround ResolvableType.forClassWithGenerics bug
Temporarily work around SPR-16456
parent
60d525e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
CollectionBinder.java
...mework/boot/context/properties/bind/CollectionBinder.java
+1
-1
IndexedElementsBinder.java
...k/boot/context/properties/bind/IndexedElementsBinder.java
+13
-2
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java
View file @
f24c92c6
...
@@ -40,7 +40,7 @@ class CollectionBinder extends IndexedElementsBinder<Collection<Object>> {
...
@@ -40,7 +40,7 @@ class CollectionBinder extends IndexedElementsBinder<Collection<Object>> {
AggregateElementBinder
elementBinder
)
{
AggregateElementBinder
elementBinder
)
{
Class
<?>
collectionType
=
(
target
.
getValue
()
==
null
?
target
.
getType
().
resolve
()
Class
<?>
collectionType
=
(
target
.
getValue
()
==
null
?
target
.
getType
().
resolve
()
:
List
.
class
);
:
List
.
class
);
ResolvableType
aggregateType
=
ResolvableType
.
forClassWithGenerics
(
List
.
class
,
ResolvableType
aggregateType
=
forClassWithGenerics
(
List
.
class
,
target
.
getType
().
asCollection
().
getGenerics
());
target
.
getType
().
asCollection
().
getGenerics
());
ResolvableType
elementType
=
target
.
getType
().
asCollection
().
getGeneric
();
ResolvableType
elementType
=
target
.
getType
().
asCollection
().
getGeneric
();
IndexedCollectionSupplier
result
=
new
IndexedCollectionSupplier
(
IndexedCollectionSupplier
result
=
new
IndexedCollectionSupplier
(
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java
View file @
f24c92c6
...
@@ -79,8 +79,8 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> {
...
@@ -79,8 +79,8 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> {
ConfigurationProperty
property
=
source
.
getConfigurationProperty
(
root
);
ConfigurationProperty
property
=
source
.
getConfigurationProperty
(
root
);
if
(
property
!=
null
)
{
if
(
property
!=
null
)
{
Object
aggregate
=
convert
(
property
.
getValue
(),
aggregateType
);
Object
aggregate
=
convert
(
property
.
getValue
(),
aggregateType
);
ResolvableType
collectionType
=
ResolvableType
ResolvableType
collectionType
=
forClassWithGenerics
(
.
forClassWithGenerics
(
collection
.
get
().
getClass
(),
elementType
);
collection
.
get
().
getClass
(),
elementType
);
Collection
<
Object
>
elements
=
convert
(
aggregate
,
collectionType
);
Collection
<
Object
>
elements
=
convert
(
aggregate
,
collectionType
);
collection
.
get
().
addAll
(
elements
);
collection
.
get
().
addAll
(
elements
);
}
}
...
@@ -140,6 +140,17 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> {
...
@@ -140,6 +140,17 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> {
return
ResolvableTypeDescriptor
.
forType
(
type
).
convert
(
conversionService
,
value
);
return
ResolvableTypeDescriptor
.
forType
(
type
).
convert
(
conversionService
,
value
);
}
}
// Work around for SPR-16456
protected
static
ResolvableType
forClassWithGenerics
(
Class
<?>
type
,
ResolvableType
...
generics
)
{
ResolvableType
[]
resolvedGenerics
=
new
ResolvableType
[
generics
.
length
];
for
(
int
i
=
0
;
i
<
generics
.
length
;
i
++)
{
resolvedGenerics
[
i
]
=
forClassWithGenerics
(
generics
[
i
].
resolve
(),
generics
[
i
].
getGenerics
());
}
return
ResolvableType
.
forClassWithGenerics
(
type
,
resolvedGenerics
);
}
/**
/**
* {@link AggregateBinder.AggregateSupplier AggregateSupplier} for an indexed
* {@link AggregateBinder.AggregateSupplier AggregateSupplier} for an indexed
* collection.
* collection.
...
...
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