The _current_ behaviour is the same but the semantics is different between calling `flush()` and `ensureCapacity(remaining data length in the buffer)`.  What we need to make sure in  `writePayload(src)` is to dump the remaining contents in the buffer so that we can use the user input as the source buffer. 

There is no guarantee that `ensureCapacity(...)` calls `flush()`. The current implementation that calls `flush()` might change due to some optimization.