Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(PageBufferReader): should conform to io.Reader interface (dgraph-…
…io#1935) Fixes DGRAPHCORE-121 ## Problem The CI build was showing sporadic failures of TestPagebufferReader2 with the error message: Received unexpected error: EOF The result is sporadic because the test case relied on randomized behavior. In particular, it would generate a read-buffer of some random length, which could occasionally have a length of 0. When the length is 0, we would encounter this error. The cause is from the PageBufferReader having incorrect behavior for the Read(p []byte) function: In particular, when p is empty, based on the expected behavior of the Reader interface, this should return 0, nil. However, this is currently returning 0, EOF. ## Solution I added a unit test to make sure we consider the empty buffer input in every case (instead of just randomly every once in a while). This doesn't actually provide a solution, but it makes sure that we don't end up with a regression in this area. At the point where we currently detect that we read 0 bytes, before just returning 0, EOF, I add a check to make sure that the value p has non-zero length.
- Loading branch information