Closed cgrushko closed 1 month ago
Yeah, good advice. Wanna send a pull request? Otherwise I’m happy to fix it.
Yeah, good advice. Wanna send a pull request? Otherwise I’m happy to fix it.
It's a bit of a process to get the CLA signed for me, so I'd appreciate if you could take it. Also would like to take the opportunity to thank you folks for writing and maintaining okio and okhttp - it's an amazing piece of software :)
Repro:
The code in JDK 21+35 LTS is:
which effectively calls
read(buf, 0, 10) --> returns 10, do another iteration read(buf, 10, 0) --> gets stuck
IMO it's a reasonable implementation of readNBytes.
When we call
read(0)
, RealBufferedSource.read() will call PipeSource.read(8192), which will block as it should. If RealBufferedSource.read() could return immediately when length=0, we won't get blocked.