Skip to content

@ExceptionHandler returns 406 when Controller method returns Mono<String> and exception handler returns Mono<Map<String,String>> and Controller method returns Mono.error #15691

Closed
@bidadh

Description

@bidadh

Hi,

I've created this repo: https://github.com/bidadh/exception-handling-issue to demonstrate the issue.

You can simply run mvn spring-boot:run and try different http-reques files in the project.

if you try:
GET http://localhost:8080/mono-error-long

or any other requests you'll receive the correct response:

GET http://localhost:8080/mono-error-long

HTTP/1.1 409 Conflict
Content-Type: application/json;charset=UTF-8
Content-Length: 74

{
    "message": "Error Happened",
    "req": "http://localhost:8080/mono-error-long"
}

However, if you run the following:
GET http://localhost:8080/mono-error-string-map

you'll receive this response:

HTTP/1.1 406 Not Acceptable
Content-Type: application/json;charset=UTF-8
Content-Length: 167

{
    "timestamp": "2019-01-12T15:45:47.734+0000",
    "path": "/mono-error-string-map",
    "status": 406,
    "error": "Not Acceptable",
    "message": "Could not find acceptable representation"

Thanks,
Arthur

Metadata

Metadata

Assignees

Labels

status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions