Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE in BQ's StandardTableDefinition #4247

Merged
merged 1 commit into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public static class StreamingBuffer implements Serializable {
}

/** Returns a lower-bound estimate of the number of rows currently in the streaming buffer. */
public long getEstimatedRows() {
public Long getEstimatedRows() {
return estimatedRows;
}

/** Returns a lower-bound estimate of the number of bytes currently in the streaming buffer. */
public long getEstimatedBytes() {
public Long getEstimatedBytes() {
return estimatedBytes;
}

Expand Down Expand Up @@ -95,10 +95,17 @@ public boolean equals(Object obj) {
}

Streamingbuffer toPb() {
return new Streamingbuffer()
.setEstimatedBytes(BigInteger.valueOf(estimatedBytes))
.setEstimatedRows(BigInteger.valueOf(estimatedRows))
.setOldestEntryTime(BigInteger.valueOf(oldestEntryTime));
Streamingbuffer buffer = new Streamingbuffer();
if (estimatedBytes != null) {
buffer.setEstimatedBytes(BigInteger.valueOf(estimatedBytes));
}
if (estimatedRows != null) {
buffer.setEstimatedRows(BigInteger.valueOf(estimatedRows));
}
if (oldestEntryTime != null) {
buffer.setOldestEntryTime(BigInteger.valueOf(oldestEntryTime));
}
return buffer;
}

static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public void testFromPbWithNullEstimatedRowsAndBytes() {
TABLE_DEFINITION.toPb().setStreamingBuffer(new Streamingbuffer()));
}

@Test
public void testStreamingBufferWithNullFieldsToPb() {
new StreamingBuffer(null, null, null).toPb();
}

private void compareStandardTableDefinition(
StandardTableDefinition expected, StandardTableDefinition value) {
assertEquals(expected, value);
Expand Down