Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
handle null records case
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Gray authored and Adam Gray committed Feb 13, 2017
1 parent 368e526 commit af27613
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ List<List<Record>> makeBatches(List<Record> records) {

for (Record record : records) {

if (record == null) {
continue;
}

Integer recSize = record.getData().remaining();

if (numRecords + 1 > 500 || byteSize + recSize > 4194304) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ public void testNoRecordsCase() throws IOException {
verify(firehoseClientMock, buffer);
}

@Test
public void testNullRecordsCase() throws IOException {
ArrayList<Record> recs = new ArrayList<Record>();
recs.add(null);
expect(buffer.getRecords()).andReturn(recs);

replay(firehoseClientMock, buffer);

List<Record> failures = emitter.emit(buffer);
Assert.assertTrue(failures.isEmpty());

verify(firehoseClientMock, buffer);
}

@Test
public void testWorkingCaseNoFailures() throws IOException, InterruptedException, ExecutionException {
List<Record> records = generateRecords(1750);
Expand Down

0 comments on commit af27613

Please sign in to comment.