Repository navigation
SPR-14818 - Implement MissingServletRequestAttributeException - #1839
carterkozak wants to merge 1 commit into
Conversation
|
The same point can be made for Session attributes, or even more broadly. This would normally require a ticket (as per our guidelines) but there is one already SPR-14818 where this belongs. |
|
Thanks for the link @rstoyanchev! I'll implement this for session attributes as well. |
Implemented RequestAttributeMethodArgumentResolverTests and MissingServletRequestAttributeException for missing request and session attributes respectively. Provides a way to programatically detect when specific attributes are not provided.
86e8690 to
fff8a69
Compare
|
I'm not sure if the solution will follow the route of one exception for every kind of input. As indicated under SPR-14818 there are a quite a few of those. Perhaps some sort of NameValueBindingException could address the need more generally. |
|
That makes sense. I would like to have a mechanism to differentiate missing headers from missing request attributes, for example. We could accomplish this with simple interface and enum implementation, though in that case the complexity is similar to implementing a custom exception type for each resolver. |
|
Since missing request attributes or session attributes are effectively state assertions within the application, I don't see a need for a dedicated exception type here, unless a compelling case can be made that the name of the attribute needs to be programmatically processed. The current resolution of SPR-14818 differentiates all remaining request-specific exceptions (request header, cookie, matrix variable) through specific exception types, allowing for HTTP status codes, so at least these attribute assertions here are now quite isolated in rest-of-ServletRequestBindingException which effectively indicate server-internal assertion errors. |
Provides a way to programatically detect when specific attributes
are not provided.