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

Even using OptionalDecoder I get an exception on 404 #2340

Open
ramgom opened this issue Mar 4, 2024 · 1 comment
Open

Even using OptionalDecoder I get an exception on 404 #2340

ramgom opened this issue Mar 4, 2024 · 1 comment

Comments

@ramgom
Copy link

ramgom commented Mar 4, 2024

Given this feign client:

`interface UserClient {

@RequestLine("GET /users/{name}")
fun getUser(@Param("name") name: String): Optional<User>

}`

val userClient = Feign.builder() .encoder(JacksonEncoder(objectMapper)) .decoder(OptionalDecoder(JacksonDecoder(objectMapper))) .target(UserClient::class.java, BASE_URL)

when I unit test this:

`
WireMock.stubFor(
WireMock.get("/users/test")
.willReturn(WireMock.notFound())
)

    userClient.getUser("test")

`

I'm getting this exception: [404 Not Found] during [GET] to [http://localhost:7070/users/test] [UserClient#getUser(String)]: []

And I was expecting to actually get an empty optional.

@gromspys
Copy link
Contributor

@ramgom try to use dismiss404():

val userClient = Feign.builder()
    .dismiss404()
    .encoder(JacksonEncoder(objectMapper))
    .decoder(OptionalDecoder(JacksonDecoder(objectMapper)))
    .target(UserClient::class.java, BASE_URL)

I think it should help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants