Closed jonaskahn closed 3 weeks ago
What will be the output if your controller returns null?
If we make the mapping function to returns a nullable response, a new error is generated:
@Throws(Exception::class)
override fun install(app: io.jooby.Jooby) {
/** See [Controller.nullable] */
app.get("/", this::nullable)
^^^^^^^^^^^^^ problem is here
.setReturnType(String::class.java)
.setMvcMethod(Controller::class.java.getMethod("nullable"))
}
fun nullable(ctx: io.jooby.Context): String? {
val c = this.factory.apply(ctx)
return c.nullable()
}
ERROR: Inapplicable candidate(s): fun nullable(ctx: Context): String?
One solution could be:
fun nullable(ctx: io.jooby.Context): String {
val c = this.factory.apply(ctx)
return c.nullable()!!
}
I will go straight to the problem. I make a controller with return type is nullable, but it will make generate source error because the generate source somehow think return type is always not null
I think it could be a bug?