Skip to content

NullPointerException in ErrorPageFilter when a MissingServletRequestParameterException is thrown and there's no DefaultHandlerExceptionResolver #22169

@rmueller83

Description

@rmueller83

We are using Spring Boot 2.1.12 with Spring Web 5.1.3.
A controller has a method annotated with @RequestMapping and a mandatory @RequestParam parameter. When the controller is called without the mandatory parameter, Spring Web throws a MissingServletRequestParameterException without a root cause. The ErrorPageFilterin Spring Boot expects all NestedServletExceptions (which MissingServletRequestParameterException is derived from) to have a root cause, leading to the NullPointerException:

java.lang.NullPointerException
	at org.springframework.boot.web.servlet.support.ErrorPageFilter.handleException(ErrorPageFilter.java:165)
	at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:142)
	at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:66)
	at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:103)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:121)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	...

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions