Commit 01d22f81 by cdrolle Committed by Oliver Woodman

Handle empty RawCC files.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143667717
parent 8a0e76ba
......@@ -83,8 +83,11 @@ public final class RawCcExtractor implements Extractor {
while (true) {
switch (parserState) {
case STATE_READING_HEADER:
parseHeader(input);
parserState = STATE_READING_TIMESTAMP_AND_COUNT;
if (parseHeader(input)) {
parserState = STATE_READING_TIMESTAMP_AND_COUNT;
} else {
return RESULT_END_OF_INPUT;
}
break;
case STATE_READING_TIMESTAMP_AND_COUNT:
if (parseTimestampAndSampleCount(input)) {
......@@ -114,14 +117,18 @@ public final class RawCcExtractor implements Extractor {
// Do nothing
}
private void parseHeader(ExtractorInput input) throws IOException, InterruptedException {
private boolean parseHeader(ExtractorInput input) throws IOException, InterruptedException {
dataScratch.reset();
input.readFully(dataScratch.data, 0, HEADER_SIZE);
if (dataScratch.readInt() != HEADER_ID) {
throw new IOException("Input not RawCC");
if (input.readFully(dataScratch.data, 0, HEADER_SIZE, true)) {
if (dataScratch.readInt() != HEADER_ID) {
throw new IOException("Input not RawCC");
}
version = dataScratch.readUnsignedByte();
// no versions use the flag fields yet
return true;
} else {
return false;
}
version = dataScratch.readUnsignedByte();
// no versions use the flag fields yet
}
private boolean parseTimestampAndSampleCount(ExtractorInput input) throws IOException,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment