Skip to content

NPE in JpaQueryCreator when query result is projection-based interface #2408

Closed
@cigaly

Description

@cigaly

Bug has been introduced in Spaing Data JPA 2.6.1 which causes NPE to be thrown in org.springframework.data.jpa.repository.query.JpaQueryCreator when query result is projection-based interface or generic class with projection-based interface as type parameter.

Attached is simple diff file that changes org.springframework.data.jpa.repository.sample.UserRepository to demonstrate such behaviour.

While testing, if noticed that NPE is not thrown when line 181 in org.springframework.data.jpa.repository.query.JpaQueryCreator is changed from

Class<?> typeToRead = returnedType.getTypeToRead();

to

Class<?> typeToRead = returnedType.getReturnedType();

but I do not know is this can be proper fix or not.

bug.diff.txt

[Additional "feature" is that this bug is causing test to throw NPE's in infinte loop]

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions