Skip to content

Wrong URL with MvcUriComponentsBuilder::fromMethodCall in case of inheritance [SPR-13033] #17625

@spring-projects-issues

Description

@spring-projects-issues

Jean-Pierre Bergamin opened SPR-13033 and commented

MvcUriComponentsBuilder::fromMethodCall creates wrong URLs with derived controller classes, e.g.:

@RequestMapping("/something")
static class ControllerWithMethods {
	@RequestMapping("/else")
	HttpEntity<Void> myMethod(@RequestBody Object payload) {
		return null;
	}
}

@RequestMapping("/extended")
static class ExtendedController extends ControllerWithMethods {
		
}

UriComponents uriComponents = fromMethodCall(on(ExtendedController.class).myMethod(null)).build();

The URL that is built is http://localhost/something/else instead of http://localhost/extended/else.

The @RequestMapping of the declaring class of the method that is called is used instead of the @RequstMapping of the given controller class.


Affects: 4.1.6

Referenced from: commits 85cf4e6, e41877d

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions