Supports force disabling closeAfterDecode for configured types
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.8k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 41
Description
Currently Feign supports configure closeAfterDecode globally and enabled by default, It make sense for most use case, except for streaming types. for example, I'm using spring-cloud-openfeign
@GetMapping
public org.springframework.core.io.Resource download();
@GetMapping
public org.springframework.core.io.InputStreamResource streamingDownload();
If the return type is Resource the underlying InputStream is ByteArrayInputStream, response is drained and closed, it's not streaming and not suitable for large stream, then we should use InputStreamResource for real streaming, but the stream is closed by feign.
Caused by: java.io.IOException: closed
at okio.RealBufferedSource$1.read(RealBufferedSource.java:443)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at java.io.PushbackInputStream.read(PushbackInputStream.java:186)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.readLine(BufferedReader.java:324)
at java.io.BufferedReader.readLine(BufferedReader.java:389)
at java.io.BufferedReader$1.hasNext(BufferedReader.java:571)
... 75 more
It would be nice if feign provide method doNotCloseFor like doNotCloseAfterDecode
public Builder doNotCloseFor(Class<?>... types) {
// TODO
return this;
}
public Builder doNotCloseAfterDecode() {
this.closeAfterDecode = false;
return this;
}
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 Feign Builder methods closeAfterDecode and doNotCloseAfterDecode shown in the issue, then trace where response streams are closed during decoding. Define how configured return types should bypass closing while preserving the default behavior, and verify that streaming responses remain readable without breaking ordinary decoded responses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100