GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Protobuf fields should not be checked for nullness · Issue #752 · googleapis/sdk-platform-java

This repository was archived by the owner on Oct 29, 2026. It is now read-only.
This repository was archived by the owner on Oct 29, 2026. It is now read-only.

Protobuf fields should not be checked for nullness #752

Copy link
Copy link
Closed
Closed
Protobuf fields should not be checked for nullness#752
Copy link
Assignees
miraleung
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@dpcollins-google
dpcollins-google
opened on Jun 7, 2021
Issue body actions

Java codegen for list methods should not generate null checks like this one for proto fields https://github.com/googleapis/java-pubsublite/blob/da98b0f8212d33ace2e3f9d034f7a923ef05c43a/google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/v1/stub/AdminServiceStubSettings.java#L187

This is a hard blocker for pulling these libraries into the google codebase which has a compiler error for null checks on protobuf fields. Per https://developers.google.com/protocol-buffers/docs/reference/java-generated, java protobuf fields will never return null.

Environment details

  • Programming language: Java
  • OS: All
  • Language runtime version: All
  • Package version: All

Steps to reproduce

  1. Write a java client library with a list request
  2. Codegen adds redundant check

Activity

  1. dpcollins-google
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    on Jun 7, 2021
  2. miraleung
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    and removed
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    on Jun 7, 2021
  3. miraleung
    self-assigned this
    on Jun 7, 2021
  4. miraleung commented on Jun 7, 2021

    @miraleung
    miraleung
    on Jun 7, 2021
    Contributor
    More actions

    @Neenu1995 @chingor13 FYI

  5. miraleung commented on Jun 7, 2021

    @miraleung
    miraleung
    on Jun 7, 2021
    Contributor
    More actions

    This null check originates from the monolith generator. On investigating, this was introduced for a very specific reason, context below.

    • Original bug
    • Relevant discussion in the bugfix, where the necessity of this check was initially debated.

    I'll add a comment to the code to indicate this check is WAI. Removing this check would introduce a bug in client libraries who do return null instead of an empty list, so closing this issue.

  6. miraleung
    closed this as completedon Jun 7, 2021
  7. dpcollins-google commented on Jun 7, 2021

    @dpcollins-google
    dpcollins-google
    on Jun 7, 2021
    Author
    More actions

    Going to reopen. The bug and discussion refer to com.google.api.services.compute.model.Image, note the model in the name. This refers to the old HTTP generated libraries, not protobuf libraries, indeed you can see it overrides GenericJson not AbstractMessage. Are there still generated clients which use the old HTTP bindings, not the protobuf ones? If so, this check may indeed be necessary for those clients. But if no such libraries are generated (or generatable) with the version at head, this check may safely be removed.

  8. dpcollins-google
    reopened this on Jun 7, 2021
  9. miraleung commented on Jun 7, 2021

    @miraleung
    miraleung
    on Jun 7, 2021
    Contributor
    More actions

    The microgenerator supports a superset of the monolith's features, and it's unclear if there are clients who do the same thing as the use case mentioned in the original bug. I would prefer not to introduce a potential breakage to one of the ~200 client libraries we support, but if you can confirm that none of them return null instead of an empty list (and paste that here), we can revisit making this change.

    In the meantime, the import issue can be addressed by post-processing the generated library, either manually (as is currently done) or with a script.

  10. miraleung
    closed this as completedon Jun 7, 2021
  11. suztomo
    added 3 commits that reference this issue on Mar 21, 2023

    deps: update dependency io.grpc:grpc-bom to v1.48.0 (#752)

    9678d52

    chore(main): release 3.0.0 (#740)

    f0625b0

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

    2eb4367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @miraleung
    miraleung

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.