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

Prevent NPE from occurring

Open birariro opened this issue 1 year ago • 2 comments

Hi, I think NotNull Message looks better than NPE.

  • [x] You have read the Spring Data contribution guidelines.
  • [x] You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • [x] You submit test cases (unit or integration tests) that back your changes.
  • [x] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

birariro avatar Feb 08 '24 04:02 birariro

How did you encounter a null pointer at ValidationErrors? Do you have a stack trace handy?

mp911de avatar Feb 08 '24 08:02 mp911de

There is no reason for an NPE to occur in ValidationErrors. But if you look at the existing code Assert.notNull(source, "Entity must not be null");

Since there is a logic to check null, I thought we considered the possibility of it occurring.

birariro avatar Feb 09 '24 06:02 birariro