Skip to content

Feign client returns null for non-nullable return value #1595

@Lunkers

Description

@Lunkers

Hello,
I'm using a feign client that looks something like this:

@FeignClient("api", url = "\${api-url}", decode404 = true)
interface Client {

    @GetMapping("/api/article/{id}")
    fun getLatestRevision(
        @PathVariable("id") id: String,
    ): Optional<ArticleRevision>


    @GetMapping("/api/video/{id}/revision/{revision}")
    fun getRevision(
        @PathVariable("id") id: String,
        @PathVariable("revision") revision: Int
    ): ArticleRevision
}

The assumption that I'm making is that when the first method gets a 404 response, it should return Optional.empty, which it does. But since the return type of the second method is not nullable, I would assume that an exception would be thrown if the response is 404. However, this does not happen and the function just returns null. Is this expected behavior? Can I not use decode404 and expect a non-nullable return value to not be null?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions