Response interceptor is not intercepting response
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.8k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 41
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ResponseInterceptor and aroundDecode contract, then inspect the connector builder registration shown in the issue and compare it with the README interceptor example. Reproduce the 409 case with MyResponseInterceptor and trace whether aroundDecode is invoked; done means the behavior or its usage is clarified, with the README example and RedirectionInterceptor discrepancy addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100