Skip to content

Commit eb17120

Browse files
authored
chore: Add comment context on null protobuf check [ggj] (#754)
* chore: Add comment context on null protobuf check * Update AbstractServiceStubSettingsClassComposer.java
1 parent 1e24893 commit eb17120

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,14 @@ private static Expr createPagedListDescriptorAssignExpr(
580580
String.format("get%sList", JavaStyle.toUpperCamelCase(repeatedFieldName)))
581581
.setReturnType(returnType)
582582
.build();
583+
584+
// While protobufs should not be null, this null-check is needed to protect against NPEs
585+
// in paged iteration on clients that use legacy HTTP/JSON types, as these clients can
586+
// actually return null instead of an empty list.
587+
// Context:
588+
// Original issue: https://github.com/googleapis/google-cloud-java/issues/3736
589+
// Relevant discussion where this check was first added:
590+
// https://github.com/googleapis/google-cloud-java/pull/4499#discussion_r257057409
583591
Expr conditionExpr =
584592
RelationalOperationExpr.equalToWithExprs(getResponsesListExpr, ValueExpr.createNullExpr());
585593
Expr thenExpr =

0 commit comments

Comments
 (0)