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

Protobuf fields should not be checked for nullness #752

Closed
dpcollins-google opened this issue Jun 7, 2021 · 4 comments
Closed

Protobuf fields should not be checked for nullness #752

dpcollins-google opened this issue Jun 7, 2021 · 4 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@dpcollins-google
Copy link

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
@dpcollins-google dpcollins-google added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jun 7, 2021
@miraleung miraleung added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jun 7, 2021
@miraleung miraleung self-assigned this Jun 7, 2021
@miraleung
Copy link
Contributor

@Neenu1995 @chingor13 FYI

@miraleung
Copy link
Contributor

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

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.

@dpcollins-google
Copy link
Author

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.

@miraleung
Copy link
Contributor

miraleung commented Jun 7, 2021

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.

suztomo pushed a commit that referenced this issue Mar 21, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [io.grpc:grpc-bom](https://togithub.com/grpc/grpc-java) | `1.47.0` -> `1.48.0` | [![age](https://badges.renovateapi.com/packages/maven/io.grpc:grpc-bom/1.48.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/io.grpc:grpc-bom/1.48.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/io.grpc:grpc-bom/1.48.0/compatibility-slim/1.47.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/io.grpc:grpc-bom/1.48.0/confidence-slim/1.47.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>grpc/grpc-java</summary>

### [`v1.48.0`](https://togithub.com/grpc/grpc-java/compare/v1.47.0...v1.48.0)

[Compare Source](https://togithub.com/grpc/grpc-java/compare/v1.47.0...v1.48.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-shared-dependencies).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMTcuNCIsInVwZGF0ZWRJblZlciI6IjMyLjExNy40In0=-->
suztomo pushed a commit that referenced this issue Mar 21, 2023
🤖 I have created a release *beep* *boop*
---


## [3.0.0](googleapis/java-shared-dependencies@v2.13.0...v3.0.0) (2022-07-29)


### Bug Fixes

* enable longpaths support for windows test ([#1485](https://github.com/googleapis/java-shared-dependencies/issues/1485)) ([#738](googleapis/java-shared-dependencies#738)) ([48b157d](googleapis/java-shared-dependencies@48b157d))


### Dependencies

* update dependency com.google.api-client:google-api-client-bom to v1.35.2 ([#729](googleapis/java-shared-dependencies#729)) ([d518319](googleapis/java-shared-dependencies@d518319))
* update dependency com.google.api-client:google-api-client-bom to v2 ([#746](googleapis/java-shared-dependencies#746)) ([ef2b57a](googleapis/java-shared-dependencies@ef2b57a))
* update dependency com.google.api.grpc:grpc-google-common-protos to v2.9.2 ([#741](googleapis/java-shared-dependencies#741)) ([347269f](googleapis/java-shared-dependencies@347269f))
* update dependency com.google.auth:google-auth-library-bom to v1.8.0 ([#726](googleapis/java-shared-dependencies#726)) ([236bbb3](googleapis/java-shared-dependencies@236bbb3))
* update dependency com.google.auth:google-auth-library-bom to v1.8.1 ([#742](googleapis/java-shared-dependencies#742)) ([dabdbdf](googleapis/java-shared-dependencies@dabdbdf))
* update dependency com.google.cloud:first-party-dependencies to v2 ([#747](googleapis/java-shared-dependencies#747)) ([93b1ed8](googleapis/java-shared-dependencies@93b1ed8))
* update dependency com.google.cloud:grpc-gcp to v1.2.1 ([#751](googleapis/java-shared-dependencies#751)) ([618b00c](googleapis/java-shared-dependencies@618b00c))
* update dependency com.google.cloud:third-party-dependencies to v2 ([#748](googleapis/java-shared-dependencies#748)) ([afca3fd](googleapis/java-shared-dependencies@afca3fd))
* update dependency com.google.http-client:google-http-client-bom to v1.42.1 ([#730](googleapis/java-shared-dependencies#730)) ([4fdaad8](googleapis/java-shared-dependencies@4fdaad8))
* update dependency com.google.http-client:google-http-client-bom to v1.42.2 ([#749](googleapis/java-shared-dependencies#749)) ([68a82f4](googleapis/java-shared-dependencies@68a82f4))
* update dependency com.google.protobuf:protobuf-bom to v3.21.2 ([#722](googleapis/java-shared-dependencies#722)) ([68f570e](googleapis/java-shared-dependencies@68f570e))
* update dependency com.google.protobuf:protobuf-bom to v3.21.3 ([#756](googleapis/java-shared-dependencies#756)) ([7429507](googleapis/java-shared-dependencies@7429507))
* update dependency com.google.protobuf:protobuf-bom to v3.21.4 ([#759](googleapis/java-shared-dependencies#759)) ([f033db0](googleapis/java-shared-dependencies@f033db0))
* update dependency io.grpc:grpc-bom to v1.48.0 ([#752](googleapis/java-shared-dependencies#752)) ([9678d52](googleapis/java-shared-dependencies@9678d52))
* update dependency org.checkerframework:checker-qual to v3.23.0 ([#736](googleapis/java-shared-dependencies#736)) ([816d380](googleapis/java-shared-dependencies@816d380))
* update gax.version to v2.18.3 ([#731](googleapis/java-shared-dependencies#731)) ([5bbf1e1](googleapis/java-shared-dependencies@5bbf1e1))
* update gax.version to v2.18.4 ([#735](googleapis/java-shared-dependencies#735)) ([5161c6e](googleapis/java-shared-dependencies@5161c6e))
* update gax.version to v2.18.5 ([#758](googleapis/java-shared-dependencies#758)) ([608e040](googleapis/java-shared-dependencies@608e040))
* update gax.version to v2.18.6 ([#763](googleapis/java-shared-dependencies#763)) ([84b81e9](googleapis/java-shared-dependencies@84b81e9))
* update google.common-protos.version to v2.9.1 ([#724](googleapis/java-shared-dependencies#724)) ([62cd59a](googleapis/java-shared-dependencies@62cd59a))
* update google.core.version to v2.8.1 ([#725](googleapis/java-shared-dependencies#725)) ([d47af56](googleapis/java-shared-dependencies@d47af56))
* update google.core.version to v2.8.3 ([#760](googleapis/java-shared-dependencies#760)) ([33e38dc](googleapis/java-shared-dependencies@33e38dc))
* update google.core.version to v2.8.4 ([#762](googleapis/java-shared-dependencies#762)) ([5410450](googleapis/java-shared-dependencies@5410450))
* update google.core.version to v2.8.5 ([#764](googleapis/java-shared-dependencies#764)) ([4bc8c75](googleapis/java-shared-dependencies@4bc8c75))
* update iam.version to v1.5.0 ([#732](googleapis/java-shared-dependencies#732)) ([3e64541](googleapis/java-shared-dependencies@3e64541))
* update iam.version to v1.5.1 ([#737](googleapis/java-shared-dependencies#737)) ([5a85115](googleapis/java-shared-dependencies@5a85115))
* update iam.version to v1.5.2 ([#743](googleapis/java-shared-dependencies#743)) ([294ea85](googleapis/java-shared-dependencies@294ea85))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
suztomo pushed a commit that referenced this issue Mar 21, 2023
…onfig to v1.3.0 (#752)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:google-cloud-shared-config](https://togithub.com/googleapis/java-shared-config) | `1.2.7` -> `1.3.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.3.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.3.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.3.0/compatibility-slim/1.2.7)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.3.0/confidence-slim/1.2.7)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-shared-config</summary>

### [`v1.3.0`](https://togithub.com/googleapis/java-shared-config/blob/HEAD/CHANGELOG.md#&#8203;130-httpsgithubcomgoogleapisjava-shared-configcomparev127v130-2022-03-07)

[Compare Source](https://togithub.com/googleapis/java-shared-config/compare/v1.2.7...v1.3.0)

##### Features

-   increase IT timeout from 20 to 60 mins ([#&#8203;440](https://togithub.com/googleapis/java-shared-config/issues/440)) ([a4427bc](https://togithub.com/googleapis/java-shared-config/commit/a4427bceebd0624e23f0b02bb24d7ed46ea4b3a6))

##### Dependencies

-   update dependency com.google.cloud:native-image-support to v0.12.6 ([#&#8203;423](https://togithub.com/googleapis/java-shared-config/issues/423)) ([9a0cb79](https://togithub.com/googleapis/java-shared-config/commit/9a0cb79896d5c97dc3c5648a6740d53eb9ada673))
-   update dependency com.puppycrawl.tools:checkstyle to v9.3 ([#&#8203;415](https://togithub.com/googleapis/java-shared-config/issues/415)) ([9e2d3fd](https://togithub.com/googleapis/java-shared-config/commit/9e2d3fd8bd42bc210dae5798f7d5dfe950c29f51))
-   update dependency org.graalvm.buildtools:junit-platform-native to v0.9.10 ([#&#8203;429](https://togithub.com/googleapis/java-shared-config/issues/429)) ([0355f29](https://togithub.com/googleapis/java-shared-config/commit/0355f2988ebcff19615b72bc65523555e4844523))
-   update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.10 ([#&#8203;430](https://togithub.com/googleapis/java-shared-config/issues/430)) ([16984d2](https://togithub.com/googleapis/java-shared-config/commit/16984d25a84aa6a8daf2a0925ea57cd0d3f0ee24))

##### [1.2.7](https://togithub.com/googleapis/java-shared-config/compare/v1.2.6...v1.2.7) (2022-02-04)

##### Dependencies

-   update dependency com.google.cloud:native-image-support to v0.12.0 ([#&#8203;414](https://togithub.com/googleapis/java-shared-config/issues/414)) ([2133cc0](https://togithub.com/googleapis/java-shared-config/commit/2133cc093efd8420e352274f3eab09de819ff796))

##### [1.2.6](https://togithub.com/googleapis/java-shared-config/compare/v1.2.5...v1.2.6) (2022-01-19)

##### Bug Fixes

-   library should released as 1.2.6 ([#&#8203;408](https://togithub.com/googleapis/java-shared-config/issues/408)) ([4972daa](https://togithub.com/googleapis/java-shared-config/commit/4972daa60467797566c4b043cebd322577b8eb73))

##### [1.2.5](https://togithub.com/googleapis/java-shared-config/compare/v1.2.4...v1.2.5) (2022-01-11)

##### Bug Fixes

-   **java:** Enable unit tests in generated libraries for native image testing ([#&#8203;394](https://togithub.com/googleapis/java-shared-config/issues/394)) ([a453b9f](https://togithub.com/googleapis/java-shared-config/commit/a453b9f141c7555f2fd5333eb17d223410ab66eb))

##### [1.2.4](https://www.github.com/googleapis/java-shared-config/compare/v1.2.3...v1.2.4) (2022-01-06)

##### Dependencies

-   revert dependency com.google.googlejavaformat:google-java-format to v1.7 ([#&#8203;391](https://www.togithub.com/googleapis/java-shared-config/issues/391)) ([17077fb](https://www.github.com/googleapis/java-shared-config/commit/17077fb1a58eef7098dc5e1e9b2c78a63c5c11e1))

##### [1.2.3](https://www.github.com/googleapis/java-shared-config/compare/v1.2.2...v1.2.3) (2022-01-04)

##### Bug Fixes

-   **java:** add -ntp flag to native image testing command ([#&#8203;1299](https://www.togithub.com/googleapis/java-shared-config/issues/1299)) ([#&#8203;376](https://www.togithub.com/googleapis/java-shared-config/issues/376)) ([50e7a10](https://www.github.com/googleapis/java-shared-config/commit/50e7a10a8dca0505fd831e3dd929577d2f82b011))
-   **java:** Only enable integration tests for native image testing ([#&#8203;375](https://www.togithub.com/googleapis/java-shared-config/issues/375)) ([663f421](https://www.github.com/googleapis/java-shared-config/commit/663f421de342afcba24703079f778738045d3ff2))
-   **java:** Pass missing integration test flags to native image test commands ([#&#8203;1309](https://www.togithub.com/googleapis/java-shared-config/issues/1309)) ([#&#8203;383](https://www.togithub.com/googleapis/java-shared-config/issues/383)) ([b17b44e](https://www.github.com/googleapis/java-shared-config/commit/b17b44e37fe44ba61616417189c6b2271f3a4d18))

##### Dependencies

-   update auto-value-annotation.version to v1.9 ([#&#8203;378](https://www.togithub.com/googleapis/java-shared-config/issues/378)) ([5e1cd0e](https://www.github.com/googleapis/java-shared-config/commit/5e1cd0e39910548ec4eb6639da979c3b66411503))
-   update dependency com.google.googlejavaformat:google-java-format to v1.13.0 ([#&#8203;361](https://www.togithub.com/googleapis/java-shared-config/issues/361)) ([095d60a](https://www.github.com/googleapis/java-shared-config/commit/095d60a061a574dcf84b9fcf26dff48617a306b1))
-   update dependency com.puppycrawl.tools:checkstyle to v9.2 ([#&#8203;366](https://www.togithub.com/googleapis/java-shared-config/issues/366)) ([061df67](https://www.github.com/googleapis/java-shared-config/commit/061df676d8b2fef5bbb0ce9661d3c96fcb57e73a))
-   update dependency com.puppycrawl.tools:checkstyle to v9.2.1 ([#&#8203;382](https://www.togithub.com/googleapis/java-shared-config/issues/382)) ([1a182c5](https://www.github.com/googleapis/java-shared-config/commit/1a182c52e7c5431875296940d68c9bdfcf74be00))
-   update dependency org.graalvm.buildtools:junit-platform-native to v0.9.9 ([#&#8203;379](https://www.togithub.com/googleapis/java-shared-config/issues/379)) ([0a2b05f](https://www.github.com/googleapis/java-shared-config/commit/0a2b05ff7f649331efbc4dd540705da10691a2f1))
-   update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.8 ([#&#8203;372](https://www.togithub.com/googleapis/java-shared-config/issues/372)) ([6fe795e](https://www.github.com/googleapis/java-shared-config/commit/6fe795ede39575656ef1609bf7aac28c1d170976))
-   update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.9 ([#&#8203;380](https://www.togithub.com/googleapis/java-shared-config/issues/380)) ([f2efad5](https://www.github.com/googleapis/java-shared-config/commit/f2efad585b431fe186c7900a8171a999c689405b))
-   update dependency org.junit.vintage:junit-vintage-engine to v5.8.2 ([#&#8203;365](https://www.togithub.com/googleapis/java-shared-config/issues/365)) ([604058d](https://www.github.com/googleapis/java-shared-config/commit/604058d52dc962db9a506762926576542687285e))

##### [1.2.2](https://www.github.com/googleapis/java-shared-config/compare/v1.2.1...v1.2.2) (2021-11-16)

##### Bug Fixes

-   update dependency com.google.cloud:native-image-support to v0.10.0 ([#&#8203;358](https://www.togithub.com/googleapis/java-shared-config/issues/358)) ([0441958](https://www.github.com/googleapis/java-shared-config/commit/044195865a1122d419cadae90fddbf8dc5b4a32d))

##### [1.2.1](https://www.github.com/googleapis/java-shared-config/compare/v1.2.0...v1.2.1) (2021-11-08)

##### Bug Fixes

-   Add native image feature to register protobuf reflection in tests ([#&#8203;347](https://www.togithub.com/googleapis/java-shared-config/issues/347)) ([88c3e3b](https://www.github.com/googleapis/java-shared-config/commit/88c3e3b0ad1e480e0fdbe9f6fe1f9df183066ee6))

##### Dependencies

-   update dependency com.google.auto.service:auto-service-annotations to v1.0.1 ([#&#8203;346](https://www.togithub.com/googleapis/java-shared-config/issues/346)) ([9c1f943](https://www.github.com/googleapis/java-shared-config/commit/9c1f94345fb47346fe66f901976c2347b8102bc8))
-   update dependency com.google.cloud:native-image-support to v0.9.0 ([#&#8203;350](https://www.togithub.com/googleapis/java-shared-config/issues/350)) ([3b496b0](https://www.github.com/googleapis/java-shared-config/commit/3b496b03bd95e59fcd1a3a1eb6cc0dfd330db769))
-   update dependency com.puppycrawl.tools:checkstyle to v9.1 ([#&#8203;345](https://www.togithub.com/googleapis/java-shared-config/issues/345)) ([f5c03d3](https://www.github.com/googleapis/java-shared-config/commit/f5c03d35684ef4e0bb3178ab6056f231f3f4faf6))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-core).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
2 participants