mirror of https://github.com/grpc/grpc-java.git
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:
parent
9334b6fa32
commit
88a758236a
|
|
@ -22,15 +22,17 @@ public class InputStreamDeframer extends Deframer<InputStream> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deframing a single input stream that contains multiple GRPC frames
|
* Deframing a single input stream that contains multiple GRPC frames
|
||||||
|
*
|
||||||
|
* @return the number of unconsumed bytes remaining in the buffer
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deframe(InputStream frame, Operation target) {
|
public int deframe(InputStream frame, Operation target) {
|
||||||
try {
|
try {
|
||||||
int read = 0;
|
int remaining;
|
||||||
while (frame.available() > 0) {
|
do {
|
||||||
read += super.deframe(frame, target);
|
remaining = super.deframe(frame, target);
|
||||||
}
|
} while (frame.available() > 0);
|
||||||
return read;
|
return remaining;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new RuntimeException(ioe);
|
throw new RuntimeException(ioe);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue