Deframer.deframe returns number of unprocessed bytes.

This is intended to reduce the flakiness of test_TestServiceBenchmarks.
TAP showed some flaky runs where HttpStreamDeframer threw the exception
"GRPC stream not correctly aligned".

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69166650
This commit is contained in:
ejona 2014-06-13 11:50:18 -07:00 committed by Eric Anderson
parent 9334b6fa32
commit 88a758236a
1 changed files with 7 additions and 5 deletions

View File

@ -22,15 +22,17 @@ public class InputStreamDeframer extends Deframer<InputStream> {
/**
* Deframing a single input stream that contains multiple GRPC frames
*
* @return the number of unconsumed bytes remaining in the buffer
*/
@Override
public int deframe(InputStream frame, Operation target) {
try {
int read = 0;
while (frame.available() > 0) {
read += super.deframe(frame, target);
}
return read;
int remaining;
do {
remaining = super.deframe(frame, target);
} while (frame.available() > 0);
return remaining;
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}