Bug fix: Fixed broken data generation logic in AsyncRandomHandler (affects test code only)

This commit is contained in:
Oleg Kalnichevski 2019-03-07 11:32:16 +01:00
parent 285674e4ff
commit 7146a36f87
1 changed files with 5 additions and 5 deletions

View File

@ -197,13 +197,13 @@ public class AsyncRandomHandler implements AsyncServerExchangeHandler {
final byte b = RANGE[(int) (Math.random() * RANGE.length)];
buffer.put(b);
}
remaining -= chunk;
buffer.flip();
final int bytesWritten = channel.write(buffer);
if (bytesWritten > 0) {
remaining -= bytesWritten;
}
channel.write(buffer);
buffer.compact();
if (remaining <= 0) {
if (remaining <= 0 && buffer.position() == 0) {
channel.endStream();
}
}