Skip to content

MapMethodProcessor precludes custom argument resolvers with Map and custom annotation [SPR-17340] #21874

Closed
@spring-projects-issues

Description

@spring-projects-issues

Laplie opened SPR-17340 and commented

Spring argument resolvers are listed first in

RequestMappingHandlerAdapter.getDefaultArgumentResolvers()

As a result, the built-in argument resolvers always have precedence.  In a controller method such as:

 

@PostMapping("/foo")
public String doSomething(@MyCustomAnnotation Map<String, Object> argument)

 

Where "@MyCustomAnnotation" triggers a custom argument resolver, the custom argument resolver is NEVER used because Spring has a built-in resolver for Map.class

 

There are 2 possible simple solutions I can think of to this problem:

  1. Respect the @Order annotation on method resolvers and sort the resolver list
  2. Put the custom method resolvers BEFORE the builtin method resolvers.

In the meantime, the workaround that I have to use is not using a Map for my argument

 

 


Affects: 5.0.6

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions