Hi @adriancole and other feign folks,
Trying to implement an "OptionalAwareJacksonDecoder", it seems that the new decode404 API is rather inflexible. Here's the scenario: Assume a server interface with two methods:
Optional<Foo> getOptionalFoo();
Foo getFoo();
, and assume a Feign client with decode404() option enabled. Now, when OptionalAwareJacksonDecoder#decode gets hit, it has to decide what to return, roughly like this:
@Override
public Object decode(Response response, Type type) throws IOException, FeignException {
if (response.status() == 404) {
if (Types.getRawType(type).equals(Optional.class)) {
return Optional.absent();
} else {
// ??? should call client's ErrorDecoder and throw the error supplied, but cannot.
}
} else {
return delegate.decode(response, type); // delegate to injected JacksonDecoder
}
}
It all works fine for the getOptionalFoo() interface, but fails for the getFoo() interface, because we should really be delegating to the configured ErrorDecoder, but cannot (even if we inject it, we're not allowed to throw here).
Thoughts?
Thanks!
Robert
Hi @adriancole and other feign folks,
Trying to implement an "OptionalAwareJacksonDecoder", it seems that the new decode404 API is rather inflexible. Here's the scenario: Assume a server interface with two methods:
, and assume a Feign client with decode404() option enabled. Now, when OptionalAwareJacksonDecoder#decode gets hit, it has to decide what to return, roughly like this:
It all works fine for the getOptionalFoo() interface, but fails for the getFoo() interface, because we should really be delegating to the configured ErrorDecoder, but cannot (even if we inject it, we're not allowed to throw here).
Thoughts?
Thanks!
Robert