Skip to content
Merged
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 @@ -580,6 +580,14 @@ private static Expr createPagedListDescriptorAssignExpr(
String.format("get%sList", JavaStyle.toUpperCamelCase(repeatedFieldName)))
.setReturnType(returnType)
.build();

// While protobufs should not be null, this null-check is needed to protect against NPEs
// in paged iteration on clients that use legacy HTTP/JSON types, as these clients can
// actually return null instead of an empty list.
// Context:
// Original issue: https://github.com/googleapis/google-cloud-java/issues/3736
// Relevant discussion where this check was first added:
// https://github.com/googleapis/google-cloud-java/pull/4499#discussion_r257057409
Expr conditionExpr =
RelationalOperationExpr.equalToWithExprs(getResponsesListExpr, ValueExpr.createNullExpr());
Expr thenExpr =
Expand Down