Description
(version 11.10)
Hey team,
I need to intercept a 409
so that my service sees it as a 200
. From what I've scraped from the internet and the docs, you need to override aroundDecode
, so my simple response interceptor looks something like this:
static class MyResponseInterceptor implements ResponseInterceptor {
@Override
public Object aroundDecode(final InvocationContext invocationContext) {
final Response response = invocationContext.response();
if (response.status() == 409) {
final Response newResponse = response.toBuilder().status(200).build();
return invocationContext.decoder().decode(newResponse, invocationContext.returnType());
}
return invocationContext.proceed();
}
}
This doesn't actually do anything when I add it to my connector builder with .responseInterceptor(new MyResponseInterceptor())
. I've tried using debugging and print statements, and it doesn't seem to actually hit my custom aroundDecode
at all.
What am I doing wrong? Or perhaps I am misunderstanding the purpose of response interceptors?
Also, it would be fantastic if an example of a from-scratch response interceptor was added to the README. The README just tells us that it is possible, and gives us an example of a prebuilt response interceptor (side note, the RedirectionInterceptor
that the README says Feign includes is not actually included with the package -- auto-import does not resolve it, and I'm unable to find it anywhere in version 11.10)