Skip to content

Implementing interface in abstract class does not expose parameter annotations #24127

Closed
@cogunites

Description

@cogunites

Hello there!

The problem is with the Spring-boot-web.

Spring boot version '2.2.1.RELEASE'

The bug :

If you got interface, an abstract class and implement class, the @RequestBody annotation will not be taken to the implemented class.

Example:

public interface TheControllerInterface {
   @PostMapping("/test")
   public String returnString(@RequestBody SomeKindOfObject object);
}
public abstract class AbstractController implements TheControllerInterface {
   // It might be empty right now, but in overall I had the implementation of few methods here EXCLUDING the one in interface.
}
@RestController
@RequestMapping("/springTest")
public class Controller extends AbstractController {

      @Override
      public String returnString(SomeKindOfObject object) {
         //implementation of method.
     }
}

After checking the url endpoint /springTest/test you will see that it does not have body.
Those informations will go to @RequestParam annotation instead of @RequestBody annotation.

The url will be inheritated. Just the @RequestBody annotation will not.

Best!

PS. It looks like somebody has RequestBody username in github, to using "@" with Annotation name will provide link to that username :(

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions