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 3 compat issues #1239

Closed
pcarrier opened this issue Sep 10, 2016 · 13 comments
Closed

protobuf 3 compat issues #1239

pcarrier opened this issue Sep 10, 2016 · 13 comments
Assignees

Comments

@pcarrier
Copy link

pcarrier commented Sep 10, 2016

  • datastore-v1-protos ships com.google.protobuf.Timestamp which implements com.google.protobuf.GeneratedMessage
  • protobuf-java 3.0.2 ships com.google.protobuf.Timestamp which implements com.google.protobuf.GeneratedMessageV3
  • As a result, with protobuf-java picked by the classloader, google-cloud-datastore classes (eg com.google.datastore.v1.Value.toBuilder) trigger java.lang.VerifyError (Type 'com/google/protobuf/Timestamp' (current frame, stack[1]) is not assignable to 'com/google/protobuf/GeneratedMessage')
  • Excluding datastore-v1-protos from the classpath and generating the classes from proto ourselves then breaks google-cloud-datastore, eg because of its com/google/cloud/datastore/PathElement.toPb()Lcom/google/protobuf/GeneratedMessage;.

I don't even know where to report this, maybe the protobuf team, but I figured the Google Cloud Platform team was a safer bet given it impacts their customers.

@pcarrier
Copy link
Author

FWIW, worked around by:

  • Excluding group: 'com.google.cloud.datastore', module: 'datastore-v1-protos'
  • Instead, generating Java classes with protoc 3.0.2 for:
    • google/datastore/v1/datastore.proto
    • google/datastore/v1/entity.proto
    • google/datastore/v1/query.proto
    • google/type/latlng.proto
  • Shamelessly forking google-cloud-datastore with:
commit 4370f038b70e329d716684d846099effb9ef2cc7
Author: Pierre Carrier <[email protected]>
Date:   2016-09-10 00:31:51 -0700

    The Fix

diff --git forks/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Query.java forks/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Query.java
index eb33c02..7eb7b17 100644
--- forks/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Query.java
+++ forks/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Query.java
@@ -22,6 +22,7 @@ import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.collect.Maps;
 import com.google.protobuf.GeneratedMessage;
+import com.google.protobuf.GeneratedMessageV3;
 import com.google.protobuf.InvalidProtocolBufferException;

 import java.util.Map;
@@ -38,7 +39,7 @@ import java.util.Map;
  * @param <V> the type of the values returned by this query.
  * @see <a href="https://cloud.google.com/datastore/docs/concepts/queries">Datastore Queries</a>
  */
-public abstract class Query<V> extends Serializable<GeneratedMessage> {
+public abstract class Query<V> extends Serializable<GeneratedMessageV3> {

   private static final long serialVersionUID = -2748141759901313101L;

diff --git forks/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Serializable.java forks/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Serializable.java
index 2e30593..3f9205c 100644
--- forks/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Serializable.java
+++ forks/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Serializable.java
@@ -16,7 +16,7 @@

 package com.google.cloud.datastore;

-import com.google.protobuf.GeneratedMessage;
+import com.google.protobuf.GeneratedMessageV3;
 import com.google.protobuf.InvalidProtocolBufferException;

 import java.io.IOException;
@@ -25,7 +25,7 @@ import java.io.ObjectOutputStream;
 import java.io.ObjectStreamException;
 import java.io.StreamCorruptedException;

-abstract class Serializable<M extends GeneratedMessage> implements java.io.Serializable {
+abstract class Serializable<M extends GeneratedMessageV3> implements java.io.Serializable {

   private static final long serialVersionUID = -5565522710061949199L;

@mziccard
Copy link
Contributor

mziccard commented Sep 10, 2016

Hi @pcarrier thanks for the report, the digging, and finding a workaround. protobuf-java was recently released and most of our dependencies still use 3.0.0 betas (which did not include the GeneratedMessageV3 class). I believe you could stumble upon similar issues with other of our modules.

Sorting this out won't be easy but should at least be possible. Something that we planned to do (haven't had time yet) is to get rid of the Serializable<M extends GeneratedMessage> class, which should at least save you from forking our repos.

Another issue I see (I might be wrong though), is that datastore-v1-protos define its own com.google.protobuf.* classes, instead of depending on protobuf-java. @eddavisson is there a reason for this? Now that protobuf-java 3.0.0 is out we should depend on it. And if we cannot depend on it for whatever reason, those classes should be shaded. Otherwise we will face the same issues @pcarrier is facing as soon as we switch to protobuf-java 3.0.0 for all Veneer Toolkit services.

@garrettjonesgoogle I believe the introduction of the GeneratedMessageV3 class could also give you an headache as well. Any plans for switching everything to protobuf v3.0.0? Its important that we coordinate our efforts so that both datastore-v1-protos and VeneerToolkit update to 3.0.0 happen at the same time.

@garrettjonesgoogle
Copy link
Member

We were going to do the switch within a week or two, but hadn't chosen a specific time for it. Let me know if there is a time that works better than others.

@eddavisson
Copy link

@mziccard I don't remember why we ended up including those com.google.protobuf.* classes, but I agree that it looks like we should be able to pick them up from protobuf-java instead.

Are any of your other dependencies (e.g. BigQuery) packaging their own generate protocol buffer classes, or do they all use the google-api-services-.* packages?

@mziccard
Copy link
Contributor

Are any of your other dependencies (e.g. BigQuery) packaging their own generate protocol buffer classes, or do they all use the google-api-services-.* packages?

All services on top of gRPC are using their own google-api-services-.* package. I believe VeneerToolkit guys are taking care of releasing them.

@eddavisson
Copy link

Got it. Any plans to switch the Datastore client to gRPC?

@mziccard
Copy link
Contributor

No plans yet. Do you believe you can change to use protobuf-java any time soon? You should be able to directly jump diretcty to 3.0.0.

@eddavisson
Copy link

I can have something by the end of the week.

@eddavisson
Copy link

eddavisson commented Sep 15, 2016

New artifacts that use protobuf-java 3.0.0 (and don't include the com.google.protobuf.* classes):

<dependency>
  <groupId>com.google.cloud.datastore</groupId>
  <artifactId>datastore-v1-protos</artifactId>
  <version>1.2.0</version>
</dependency>
<dependency>
  <groupId>com.google.cloud.datastore</groupId>
  <artifactId>datastore-v1-proto-client</artifactId>
  <version>1.2.0</version>
</dependency>

@mziccard
Copy link
Contributor

Thank you @eddavisson, this was fast:)

I'll go ahead and use the new artifacts as soon as also the VeneerToolkit layer has updated to protobuf-java 3.0.0

@mziccard
Copy link
Contributor

@pcarrier this issue should be now fixed in google-cloud 0.4.0. Care to check it out?

@mziccard
Copy link
Contributor

mziccard commented Oct 4, 2016

I am closing this, please feel free to reopen if you are still experiencing the issue

@mziccard mziccard closed this as completed Oct 4, 2016
@pcarrier
Copy link
Author

pcarrier commented Oct 4, 2016

Checked yesterday, upgrade went smoothly AFAICT. Thanks!

github-actions bot pushed a commit that referenced this issue Jun 23, 2022
…13.4 (#1239)

[![Mend 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-bigquery](https://togithub.com/googleapis/java-bigquery) | `2.13.3` -> `2.13.4` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.4/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.4/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.4/compatibility-slim/2.13.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.4/confidence-slim/2.13.3)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-bigquery</summary>

### [`v2.13.4`](https://togithub.com/googleapis/java-bigquery/blob/HEAD/CHANGELOG.md#&#8203;2134-httpsgithubcomgoogleapisjava-bigquerycomparev2133v2134-2022-06-22)

[Compare Source](https://togithub.com/googleapis/java-bigquery/compare/v2.13.3...v2.13.4)

##### Dependencies

-   update dependency org.graalvm.buildtools:junit-platform-native to v0.9.12 ([#&#8203;2124](https://togithub.com/googleapis/java-bigquery/issues/2124)) ([4542ce9](https://togithub.com/googleapis/java-bigquery/commit/4542ce9a51d9756a8a06d0e33cf3a40d1e321ade))
-   update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.12 ([#&#8203;2125](https://togithub.com/googleapis/java-bigquery/issues/2125)) ([6da965f](https://togithub.com/googleapis/java-bigquery/commit/6da965f540a2cdb2eaf845301cfbfbf34b9a6866))

</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-asset).
github-actions bot pushed a commit to suztomo/google-cloud-java that referenced this issue Jul 1, 2022
🤖 I have created a release *beep* *boop*
---


## [3.4.0](googleapis/java-asset@v3.3.1...v3.4.0) (2022-06-30)


### Features

* Enable REST transport for most of Java and Go clients ([googleapis#1242](googleapis/java-asset#1242)) ([86eb248](googleapis/java-asset@86eb248))


### Bug Fixes

* update gapic-generator-java with mock service generation fixes ([googleapis#1249](googleapis/java-asset#1249)) ([7d124ad](googleapis/java-asset@7d124ad))


### Dependencies

* update dependency com.google.api.grpc:proto-google-cloud-orgpolicy-v1 to v2.2.1 ([googleapis#1245](googleapis/java-asset#1245)) ([9b0d4e9](googleapis/java-asset@9b0d4e9))
* update dependency com.google.api.grpc:proto-google-cloud-pubsub-v1 to v1.101.0 ([googleapis#1228](googleapis/java-asset#1228)) ([c5f1712](googleapis/java-asset@c5f1712))
* update dependency com.google.api.grpc:proto-google-cloud-pubsub-v1 to v1.101.1 ([googleapis#1233](googleapis/java-asset#1233)) ([42031ef](googleapis/java-asset@42031ef))
* update dependency com.google.api.grpc:proto-google-identity-accesscontextmanager-v1 to v1.3.1 ([googleapis#1246](googleapis/java-asset#1246)) ([d868803](googleapis/java-asset@d868803))
* update dependency com.google.cloud:google-cloud-bigquery to v2.13.1 ([googleapis#1227](googleapis/java-asset#1227)) ([113c52f](googleapis/java-asset@113c52f))
* update dependency com.google.cloud:google-cloud-bigquery to v2.13.3 ([googleapis#1234](googleapis/java-asset#1234)) ([7006c44](googleapis/java-asset@7006c44))
* update dependency com.google.cloud:google-cloud-bigquery to v2.13.4 ([googleapis#1239](googleapis/java-asset#1239)) ([9c59632](googleapis/java-asset@9c59632))
* update dependency com.google.cloud:google-cloud-bigquery to v2.13.6 ([googleapis#1244](googleapis/java-asset#1244)) ([a305745](googleapis/java-asset@a305745))
* update dependency com.google.cloud:google-cloud-core to v2.8.0 ([googleapis#1238](googleapis/java-asset#1238)) ([8224b02](googleapis/java-asset@8224b02))
* update dependency com.google.cloud:google-cloud-resourcemanager to v1.4.0 ([googleapis#1230](googleapis/java-asset#1230)) ([5655582](googleapis/java-asset@5655582))
* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([googleapis#1241](googleapis/java-asset#1241)) ([2ebe221](googleapis/java-asset@2ebe221))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
github-actions bot pushed a commit that referenced this issue Sep 15, 2022
…1575) (#1239)

Source-Link: googleapis/synthtool@2e9ac19
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:8175681a918181d306d9c370d3262f16b4c724cc73d74111b7d42fc985ca7f93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants