Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web handlers don't support Kotlin extensions #31876

Closed
Raphael-Kleindienst opened this issue Dec 20, 2023 · 0 comments
Closed

Web handlers don't support Kotlin extensions #31876

Raphael-Kleindienst opened this issue Dec 20, 2023 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: kotlin An issue related to Kotlin support type: regression A bug that is also a regression
Milestone

Comments

@Raphael-Kleindienst
Copy link

Raphael-Kleindienst commented Dec 20, 2023

Hi.

while migrating from spring-boot 3.1.5 -> 3.2.0 all the Exception-handlers stopped working in our project. It turns out that functions can't be declared as kotlin extension functions anymore. Here's a code sample that works as expected for spring-boot-3.1.5 and not for spring-boot-3.2.0

class DemoApplication

fun main(args: Array<String>) {
    runApplication<DemoApplication>(*args)
}

@RestController
class MyController{

    @GetMapping("/test")
    fun test() : String {throw CustomException()}

    @ExceptionHandler(CustomException::class)
    fun CustomException.handle(): ResponseEntity<Any>{
        return ResponseEntity.status(HttpStatus.I_AM_A_TEAPOT.value()).build()
    }
}

class CustomException : Throwable()
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 20, 2023
@snicoll snicoll transferred this issue from spring-projects/spring-boot Dec 20, 2023
@sdeleuze sdeleuze self-assigned this Dec 20, 2023
@sdeleuze sdeleuze added theme: kotlin An issue related to Kotlin support in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 20, 2023
@sdeleuze sdeleuze added this to the 6.1.3 milestone Dec 21, 2023
@sdeleuze sdeleuze changed the title @ExceptionHandler can't be defined as kotlin extension functions for spring-boot 3.2.0 @ExceptionHandler can't be defined as a Kotlin extension Dec 21, 2023
@sdeleuze sdeleuze changed the title @ExceptionHandler can't be defined as a Kotlin extension Web handler methods can't be defined as Kotlin extensions Dec 21, 2023
@sdeleuze sdeleuze changed the title Web handler methods can't be defined as Kotlin extensions Web handlers don't support Kotlin extensions Dec 21, 2023
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Dec 21, 2023
This commit restores support for Kotlin extensions in
web handlers, and adds support for invoking reflectively
suspending extension functions, as well as the other
features supported as of Spring Framework 6.1 like
value classes and default value for parameters.

Closes spring-projectsgh-31876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: kotlin An issue related to Kotlin support type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants