Browse Source
This proved to be a pretty difficult to find bug. If we read exactly the number of response bytes from the UnionInputStream and didn't try to read beyond that length, the last connection's InputStream is still inside of the UnionInputStream, and UnionInputStream.isEmpty() returns false. But there is no data present, so the next read request to our UnionInputStream returns EOF at a point where the HTTP client code should have started a new request in order to get more data. Instead of wrapping the UnionInputStream, push an dummy stream onto the end of it which when invoked always starts the next request and then returns EOF. The UnionInputStream will automatically pop that dummy stream out, and then read the next request's stream. This way we never get into the state where we don't think we need to run another request in order to satisfy the current read request, but we really do. The bug was hidden for so long because BasePackConnection.init() was always wrapping the InputStream into a BufferedInputStream with an 8 KiB buffer. This made the odds of us reading from the UnionInputStream the exact number of available bytes quite low, as the BufferedInputStream would always try to read a full buffer size. Change-Id: I02b5ec3ef6853688687d91de000a5fbe2354915d Signed-off-by: Shawn O. Pearce <spearce@spearce.org>stable-0.7
Shawn O. Pearce
15 years ago
1 changed files with 15 additions and 32 deletions
Loading…
Reference in new issue