spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

NullPointerException when mapping is null (such as when used with spring data cassandra repositories)

Open alexp1917 opened this issue 4 years ago • 2 comments

"mapping" can be null here, causing the .isExported() to throw a NPE.

https://github.com/spring-projects/spring-data-rest/blob/a40aec5debf496b8e29d66a720ad27989b04f2bd/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ProfileController.java#L94-L111

I thought i was using the strategy to only include annotated repositories and that would not happen (spring.data.rest.detection-strategy=annotated). I did not intend for this repository to actually be included in the profile. but it got to this point in the code and it null pointer'ed.

alexp1917 avatar Nov 03 '21 10:11 alexp1917

@alexp1917 I created a barebones project using Spring Boot + Spring Data Cassandra + Spring Data REST. I can switch spring.data.rest.detection-strategy=annotated on and off, and it works as expected.

I could NOT replicate that NullPointerException.

You can inspect my sample project => spring.data.rest.detection-strategy=annotated

Hopefully, this sample project provides something to compare against your own code and identify a difference.

gregturn avatar Nov 10 '21 18:11 gregturn

I'll aim to put together an example by the end of thanksgiving weekend. thanks for looking into this. i am reading my ticket now and realizing its a bit too open ended.

alexp1917 avatar Nov 16 '21 18:11 alexp1917