spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
919 stars 563 forks source link

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

Open alexp1917 opened 3 years ago

alexp1917 commented 3 years ago

"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.

gregturn commented 3 years ago

@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.

alexp1917 commented 2 years ago

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.