Issue #12213: Fix a buffering bug with interleaved reads and writes that
could appear on BufferedRandom streams.