-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Description
Description
In Jooby 4.0.7, routes from a base controller are not inherited by subclasses as expected.
This behavior worked correctly in Jooby 1.x.
Example
BaseController.java
@Path("/base")
public abstract class BaseController {
@GET
public String base() {
return "base";
}
@GET("/withPath")
public String withPath(@QueryParam String q) {
return "withPath";
}
@GET("/{id}")
public String getOne(Context ctx) {
return "base: " + ctx.path("id").value();
}
}
SubClass 1
@Path("/inherited")
public class Controller1552 extends BaseController {
@GET("/childOnly")
public String childOnly(Context ctx) {
return ctx.getRequestPath();
}
@POST("/childOnly")
public String childOnlyPost(Context ctx) {
return ctx.getRequestPath();
}
}
SubClass 2
@Path("/overrideMethod")
public class OverrideMethodSubClassController extends BaseController {
@POST("/user")
public String newPath(Context q) {
return "/overrideMethod/user";
}
@GET("/childOnly")
public String childOnly(Context ctx) {
return ctx.getRequestPath();
}
}
App.java
mvc(new OverrideMethodSubClassController_());
mvc(new Controller1552_());
Actual result (Jooby 4.0.7)
POST /overrideMethod/user
GET /overrideMethod/childOnly
GET /inherited/childOnly
POST /inherited/childOnly
GET /inherited
GET /inherited/withPath
GET /inherited/{id}
Expected:
/overrideMethod should also include inherited routes from BaseController.
Related
#1552
— similar issue, but this happens when multiple subclasses extend the same base controller.
Environment
- Jooby: 4.0.7
- JDK: 21
- Build: Gradle (joobyRun)