Skip to content

TypeDescriptor.forElementType() is broken for nested collections [SPR-7562] #12219

@spring-projects-issues

Description

@spring-projects-issues

Kevin Wright opened SPR-7562 and commented

The start of forElementType() is defined as:

if (getType().equals(elementType)) {
return this;
}

Unfortunately, this fails when the TypeDescriptor represents a List<List<...>>
When calling getElementType(), the call stack will be getElementType() -> getElementTypeDescriptor() -> forElementType()
at which point, the elementType field will still be null.

The equality check will therefore see that List<null> == List<null>, and so the TypeDescriptor will be returned as its own element descriptor.
This leads to a recursive definition, where the descriptor now represents a List<List<List<...<List<List<... etc.


Affects: 3.0.3

Issue Links:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions