-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issueA duplicate of another issue
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:
Lines 211 to 214 in d05803a
String text = (String) source; | |
if (!StringUtils.hasText(text)) { | |
return null; | |
} |
and think, that passing empty string for date - it's client error
SerTelnov
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issueA duplicate of another issue