Merge pull request #2525 from millmanorama/2295-final-chunk-length

record the length of the final chunk as having no window
This commit is contained in:
Richard Cordovano 2017-02-14 09:30:33 -05:00 committed by GitHub
commit 02e075ed8f

View File

@ -167,6 +167,8 @@ class Chunker implements Iterator<Chunk>, Iterable<Chunk> {
currentChunk.append(readBaseChunk());
baseChunkSizeChars = currentChunk.length(); //save the base chunk length
currentWindow.append(readWindow());
//add the window text to the current chunk.
currentChunk.append(currentWindow);
if (endOfReaderReached) {
/* if we have reached the end of the content,we won't make
* another overlapping chunk, so the length of the base chunk
@ -181,8 +183,7 @@ class Chunker implements Iterator<Chunk>, Iterable<Chunk> {
* and break any chunking loop in client code. */
ex = ioEx;
}
//add the window text to the current chunk.
currentChunk.append(currentWindow);
//sanitize the text and return a Chunk object, that includes the base chunk length.
return new Chunk(currentChunk, baseChunkSizeChars, chunkSizeBytes);
}