Closed
Description
Affects: \5.1.6
I have the following code
@GetMapping("/somepath")
public String getNextDayOfMonth(
@RequestParam(value = "target_date", required = true)
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
LocalDate targetDate
) {
return targetDate.plusDays(1).getDayOfMonth();
}
But when I execute this handler with path like /sompath?target_date=
, I get NullPointerException, because my variable target_date
is null, but I define required=true
and DateTimeFormat annotation. I thought, if I set DateTimeFormat property and execute this mapping with invalid date string (empty in my case), I will get client exception (4xx codes) instead of server exception (5xx, cause NPE it is server side exception).
I'm suspect, that problem in this line of code:
and think, that passing empty string for date - it's client error