NPE in MvcUriComponentsBuilder with no-arg target method on interface #30756
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: regression
A bug that is also a regression
Milestone
Affects: 5.3.28 (maybe others as well)
Setup:
MyController
is an interface annotated with@RequestMapping
with a method,myMethod()
, that takes no arguments and returns aModelAndView
.The code mentioned below runs in the context of the implementation of the controller.
Issue:
When we use
MvcUriComponentsBuilder
as in below (within the context of a current request, of course):then we get a
NullPointerException
from insidefromMethodCall()
because it is claiming that the list of arguments isnull
.This definitely used to work! (Alas, we've not tried it for some number of patch releases, so I can't easily identify what release broke it.)
Critically, this doesn't affect any method that takes any arguments.
Some Analysis:
The relevant bit of stack trace:
It looks like something is setting the argument array in the
MethodInvocationInfo
tonull
instead of a zero-length object array (or maybe just isn't setting it and that's the default?) but the code to work with those things is getting rather deep for me. It's all in codegen and related.More details:
We're using this approach to generate URIs that are used to implement calls that implement behaviour of controls in the web UI. It's a bit more wrapped inside our code, but I don't believe those bits of wrapping relate to the bug.
We worked around it by adding an ignorable
ModelMap
to all methods that had no other arguments (we can pass anull
for it to the proxied call that generates the URI). That's fine as a workaround for us.The text was updated successfully, but these errors were encountered: