If @FeignClient has decode404 set to true, then any method which returns Optional and gets back a 404 will instead return Optional.empty(). If that same client has a method which returns void, then no error will be reported that the call failed.

Example: You have an interface where you can GET a resource, which returns an Optional as the resource may not be present, and update an existing resource which has a void return value. If you have decode404 set to true, then GET will return Optional.empty() when it gets 404 but PUT will just return and not throw an exception when it gets 404. If you have decode404 set to false, then GET will throw an exception rather than return Optional.empty() when it gets 404 but PUT will correctly fail when it gets back 404.

@FeignClient(decode404 = true)
public interface SecondService {
    /**
     * This method will return {@link Optional#empty()} when receiving 404 rather than throwing an exception.
     * No more nulls!
     */
    @RequestMapping(method = RequestMethod.GET, value = "/foo/{id}")
    Optional<Foo> getFoo(@PathVariable("id") String id);

    /**
     * This method will silently swallow an errors when receiving 404 :(
     */
    @RequestMapping(method = RequestMethod.PUT, value = "/foo/{id}")
    void updateFoo(@PathVariable("id") String id, Foo foo);
}

Comment From: wjam

Just realised that Optional methods don't return Optional.empty on 404 :(

Comment From: ryanjbaxter

So can we close this?

Comment From: wjam

Sorry, thought this was a different issue. There is still the problem that the error is swallowed on the void updateFoo(String) method

Comment From: wjam

I raised #1590 about not returning Optional.empty()

Comment From: ryanjbaxter

Yes I saw, can we close this one then?

Comment From: wjam

No, this one was primarily about 404 errors being silently swallowed for void methods when decode404 is set.

Comment From: ryanjbaxter

I dont know how you could expect to get an error response back from a void method, the method isn't supposed to return anything.

Comment From: wjam

I would expect an exception to be thrown as there is no other way of indicating the failure.

Comment From: wjam

This is actually a problem with Feign itself rather than the Spring wrapper around it. Feign correctly handles 2xx with void (https://github.com/OpenFeign/feign/pull/72) but doesn't have the same check for decode404.

Comment From: JalODan

I understand I am quite a bit late to the party, but I would like to suggest trying to move methods returning optionals to a separate feignclient as a workaround