FeignException could not be serialized if cause class is UnknowHostException
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.8k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 41
Description
feign 10.12, 11.5.
FeignException serialization produces error when cause class is UnknowHostException.
How to reproduce:
@Test
public void testFeignSerialization() throws IOException {
try {
SomeApi target = new Feign.Builder()
.target(SomeApi.class, "https://some-non-existing-host-for-unit-test");
target.ping();
} catch (RetryableException e) {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos)) {
out.writeObject(e);
byte[] serialized = bos.toByteArray();
}
}
}
public interface SomeApi {
@RequestLine("GET /ping")
void ping();
}
This code fails trying serialize Target$HardCodedTarget instance in e.request.requestTemplate.feignTarget.
I see in RequestTemplate that it implements Serializable, but Target (field feignTarget) implementations are not Serializable.
Also UriTemplate (field uriTemplate) is not Seralizable too.
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 RequestTemplate and inspect its feignTarget and uriTemplate fields, especially Target$HardCodedTarget and UriTemplate, which the report identifies as serialization failures. Reproduce the provided test with ObjectOutputStream and add a regression test around FeignException serialization. Done means the reproduced exception can be serialized successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100