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

Using Pub/Sub JAVA client in play framework 2.5 - netty conflicts #1331

Closed
thefunkjunky opened this issue Oct 21, 2016 · 22 comments
Closed

Using Pub/Sub JAVA client in play framework 2.5 - netty conflicts #1331

thefunkjunky opened this issue Oct 21, 2016 · 22 comments
Assignees
Labels
api: logging Issues related to the Cloud Logging API. api: pubsub Issues related to the Pub/Sub API. dependencies priority: p2 Moderately-important priority. Fix may not be included in next release. status: blocked Resolving the issue is dependent on other work. triaged for GA type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@thefunkjunky
Copy link

Issue summary: Client's services are built on top of the play framework 2.5. Some of their services need to publish messages to pub/sub, but the Google Pub/Sub java api depends on netty 4.1.x, which conflicts with netty 4.0.x used by play framework 2.5.
Is there a solution to get around this?

@mziccard
Copy link
Contributor

Argh @thefunkjunky I need to be honest with you, I was expecting this issue...

This is a problem with gRPC (a dependency of ours) and Play 2.5. gRPC depends on netty 4.1, while Play 2.5 depends on netty 4.0. Unfortunately, these 2 netty versions are not binary compatible.

A possible solution (see stackoverflow) could be downgrading to Play 2.4.6 which uses netty 3.8.0 that had a completely different project structure and package names (hence no name clashes).

Play 2.6 should ship with netty 4.1 and possibly solve this issue.

@garrettjonesgoogle do you know whether gRPC people considered shading some of their dependencies? There seem to be a number of people encountering this compatibility issues.

@garrettjonesgoogle
Copy link
Member

I don't know - @ejona86 , can you comment?

@ejona86
Copy link

ejona86 commented Oct 21, 2016

So shading is a fine strategy, but since Netty is exposed through our API (e.g., you can provide your own EventLoopGroup to NettyChannelBuilder), gRPC project pre-shading can cause problems.

@garrettjonesgoogle
Copy link
Member

We may have to shade all of gRPC in google-cloud-java. There are two problematic dependencies:

  1. Guava
  2. Netty (also see: Netty incompatibility when using Pub/Sub with Dataproc #1522 - Netty conflict with Spark Google Dataproc)

@ejona86
Copy link

ejona86 commented Jan 27, 2017

I have since made grpc/grpc-java#2485. It's not submitted yet, and if you use NettyChannelBuilder directly it doesn't work well, but we can maybe push harder on that.

Guava is a different story. Would I be right to assume issues are caused by the ancient guava-jdk5 used by the v1 client libraries?

@garrettjonesgoogle
Copy link
Member

The issue with Guava isn't the guava-jdk5 dependency, it is a larger issue with the Guava deprecation policy. Basically as soon as we pick a particular version of Guava and expose types from it, that means no one can mix our library with a version of Guava that is 2 years older or 2 years newer than the version we picked. There are a fair number of consumers that this doesn't work for, e.g. Hadoop which is stuck on Guava 11.

@ejona86
Copy link

ejona86 commented Jan 27, 2017

and expose types from it

You can't do that at all, if you are going to shade. So for example, it is hard to shade Guava for gRPC when the Future stub is in play, because it uses ListenableFuture but if we shade ListenableFuture then none of the normal utilities will work and users have to use our shaded version.

@garrettjonesgoogle
Copy link
Member

Our plan was to create an interface analogous to ListenableFuture called https://github.com/googleapis/gax-java/blob/master/src/main/java/com/google/api/gax/grpc/RpcFuture.java , which allows users to add callbacks, and make a bridge from ListenableFuture to RpcFuture called https://github.com/googleapis/gax-java/blob/master/src/main/java/com/google/api/gax/grpc/ListenableFutureDelegate.java (which is package-private). What do you mean by "the normal utilities?"

@ejona86
Copy link

ejona86 commented Jan 31, 2017

Hadoop which is stuck on Guava 11.

I think the argument there is that Hadoop should be shading/using class loading magic (a la containers). Because without doing so nobody can mix Hadoop and Guava. But I do understand the general "exposing a dependency on Guava can cause problems" argument.

Our plan was to create an interface analogous to ListenableFuture called RpcFuture

Okay. And then your users can create their own utility to convert that to a ListenableFuture.

What do you mean by "the normal utilities?"

I mean things like cgc.util.concurrent.Futures. There are a lot of generic utility methods that do things with ListenableFutures.

make a bridge from ListenableFuture to RpcFuture called ListenableFutureDelegate

That's an implementation detail, right? The user of your library doesn't care about that at all, right?

Note that any reason you are using ListenableFuture in your code could be an example of why your users would want ListenableFuture.

@garrettjonesgoogle
Copy link
Member

Hadoop which is stuck on Guava 11.

I think the argument there is that Hadoop should be shading/using class loading magic (a la containers). Because without doing so nobody can mix Hadoop and Guava. But I do understand the general "exposing a dependency on Guava can cause problems" argument.

Hadoop's problem isn't just that it depends on Guava, it's that it made Guava part of its surface, so if it upgrades to a newer version of Guava, it's a breaking change for its users. If it was only an implementation detail, they could have done something like shading Guava a long time ago.

Our plan was to create an interface analogous to ListenableFuture called RpcFuture

Okay. And then your users can create their own utility to convert that to a ListenableFuture.

I was considering creating a "bridge" project that depends on Guava and connects GAX features to Guava, so that each user doesn't have to do it themselves.

What do you mean by "the normal utilities?"

I mean things like cgc.util.concurrent.Futures. There are a lot of generic utility methods that do things with ListenableFutures.

Right, but people don't have to use those utilities. This could be addressed with the "bridge" project I mentioned above.

make a bridge from ListenableFuture to RpcFuture called ListenableFutureDelegate

That's an implementation detail, right? The user of your library doesn't care about that at all, right?

That is correct.

Note that any reason you are using ListenableFuture in your code could be an example of why your users would want ListenableFuture.

The key thing that comes out of ListenableFuture is the capability of adding a callback so that a thread isn't consumed. I don't think the key is so much that exact interface as that we provide the callback capability.

@kuroneko25
Copy link

kuroneko25 commented Feb 9, 2017

I ran into a similar issue where I use grpc-all 1.1.2 and google-cloud-pubsub in the same project. Is this going to be addressed by grpc/grpc-java#2485?

Specifically this exception

Exception in thread "main" java.lang.NoSuchMethodError: io.grpc.netty.NettyChannelBuilder.build()Lio/grpc/internal/ManagedChannelImpl;
    at com.google.api.gax.grpc.InstantiatingChannelProvider.createChannel(InstantiatingChannelProvider.java:119)
    at com.google.api.gax.grpc.InstantiatingChannelProvider.getChannel(InstantiatingChannelProvider.java:106)
    at com.google.api.gax.grpc.ProviderManager.getChannel(ProviderManager.java:106)
    at com.google.api.gax.grpc.ChannelAndExecutor.create(ChannelAndExecutor.java:67)
    at com.google.api.gax.grpc.ClientSettings.getChannelAndExecutor(ClientSettings.java:78)
    at com.google.cloud.pubsub.spi.v1.PublisherClient.<init>(PublisherClient.java:182)
    at com.google.cloud.pubsub.spi.v1.PublisherClient.create(PublisherClient.java:173)

@pongad
Copy link
Contributor

pongad commented Feb 9, 2017

If I understand this correctly, the answer is yes.

The exception is NoSuchMethod not NoClassDef. So I'm guessing

  1. grpc and gax depends on different versions
  2. grpc's version takes precedence
  3. grpc's version doesn't have the build() method we need

Once that issue is addressed, things will work together again.

ccing @garrettjonesgoogle to make sure I'm diagnosing this correctly.

@garrettjonesgoogle
Copy link
Member

@pongad , that analysis looks correct to me.

@ejona86
Copy link

ejona86 commented Feb 9, 2017

No, grpc/grpc-java#2485 would not fix your issue. That issue is not related to netty itself but the netty transport in gRPC. It looks like gRPC broke an ABI (it is still source compatible) by moving the location of build(). However, NettyChannelBuilder is explicitly stated to be unstable API, so GAX shouldn't be using it or would need to shade all of grpc.

@garrettjonesgoogle
Copy link
Member

@ejona86 So does this fairly characterize the situation?:

gRPC is GA, but the only practical general-purpose transport is Netty, and the only way to use that transport is to use an @Experimental class, so for all practical purposes if you use gRPC, you will be broken between minor versions despite your best intentions.

@ejona86
Copy link

ejona86 commented Feb 17, 2017

the only way to use that transport is to use an @experimental class,

I don't agree with that. If you're talking about NettyChannelBuilder, then no, you shouldn't use it in a library. Instead, you should use ManagedChannelBuilder's forAddress(String, int) or forTarget(String).

@garrettjonesgoogle
Copy link
Member

Oh! I don't know how we ended up using NettyChannelBuilder instead of ManagedChannelBuilder. We will switch it.

@garrettjonesgoogle
Copy link
Member

googleapis/gax-java#208

@garrettjonesgoogle
Copy link
Member

I wanted to figure out where we're at for the Netty conflicts. (Guava doesn't actually seem to be relevant to the original requester, so I won't discuss that any more here.)

Gax:

In googleapis/gax-java#215, we have switched from NettyChannelBuilder to ManagedChannelBuilder (we just haven't created an artifact with it yet).

I did a grep for netty in gax-java, and it looks like there are more netty class references there that need to be changed. I have filed issue googleapis/gax-java#234 to address this.

gRPC:

@ejona86 , it looks like https://github.com/grpc/grpc-java/pull/2485/files isn't submitted yet. Is there a timeline for it?

@garrettjonesgoogle garrettjonesgoogle added the api: logging Issues related to the Cloud Logging API. label Mar 10, 2017
@garrettjonesgoogle garrettjonesgoogle changed the title Using Pub/Sub JAVA client in play framework 2.5 Using Pub/Sub JAVA client in play framework 2.5 - netty conflicts Mar 10, 2017
@ejona86
Copy link

ejona86 commented Mar 10, 2017

No, there's not a timeline; I've started an email chain to discuss prioritization. Today the solution would be for users to shade it themselves. Based on other discussions, it also sounds like the PR will be incomplete because it fails to address tcnative loading issues. But I guess that will be solved separately by netty/netty#6271 and may not impact as many users.

@garrettjonesgoogle garrettjonesgoogle added the status: blocked Resolving the issue is dependent on other work. label Mar 11, 2017
@garrettjonesgoogle garrettjonesgoogle added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed POST GA - P1 labels Apr 26, 2017
@kuroneko25
Copy link

So if we want to shade ourselves what is the best example that we can look at? What are the artifacts/classes that need to be shaded? (we use maven)

@anthmgoogle anthmgoogle added 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. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Nov 9, 2017
@pongad
Copy link
Contributor

pongad commented Jan 19, 2018

According to @garrettjonesgoogle , the latest release should shade netty and this should no longer be a problem.

Due to age of issue, I'll close this, but please either reopen or open a new issue if you continue to experience problems.

@pongad pongad closed this as completed Jan 19, 2018
github-actions bot pushed a commit that referenced this issue Sep 15, 2022
…#1331)

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

---

### Release Notes

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

### [`v2.8.11`](https://github.com/googleapis/java-core/blob/HEAD/CHANGELOG.md#&#8203;2811-httpsgithubcomgoogleapisjava-corecomparev2810v2811-2022-09-08)

[Compare Source](https://github.com/googleapis/java-core/compare/v2.8.10...v2.8.11)

##### Dependencies

-   Update dependency com.google.auth:google-auth-library-bom to v1.11.0 ([#&#8203;911](https://github.com/googleapis/java-core/issues/911)) ([4656905](https://github.com/googleapis/java-core/commit/4656905956504e4bc4fe224d1f8cd70bbab614d8))

</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).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xOTQuMiIsInVwZGF0ZWRJblZlciI6IjMyLjE5NC4yIn0=-->
github-actions bot pushed a commit that referenced this issue Sep 16, 2022
🤖 I have created a release *beep* *boop*
---


## [3.6.0](googleapis/java-asset@v3.5.0...v3.6.0) (2022-09-15)


### Features

* Add client library support for AssetService v1 BatchGetEffectiveIamPolicies API ([3919a1d](googleapis/java-asset@3919a1d))
* Add client library support for AssetService v1 BatchGetEffectiveIamPolicies API ([#1300](googleapis/java-asset#1300)) ([3919a1d](googleapis/java-asset@3919a1d))
* Release of query system ([3919a1d](googleapis/java-asset@3919a1d))


### Dependencies

* Update dependency com.google.api.grpc:proto-google-cloud-orgpolicy-v1 to v2.3.2 ([#1302](googleapis/java-asset#1302)) ([d01d900](googleapis/java-asset@d01d900))
* Update dependency com.google.api.grpc:proto-google-cloud-orgpolicy-v1 to v2.3.3 ([#1332](googleapis/java-asset#1332)) ([c1511c2](googleapis/java-asset@c1511c2))
* Update dependency com.google.api.grpc:proto-google-cloud-os-config-v1 to v2.5.2 ([#1309](googleapis/java-asset#1309)) ([cf96ee9](googleapis/java-asset@cf96ee9))
* Update dependency com.google.api.grpc:proto-google-cloud-pubsub-v1 to v1.102.11 ([#1297](googleapis/java-asset#1297)) ([d56eedd](googleapis/java-asset@d56eedd))
* Update dependency com.google.api.grpc:proto-google-cloud-pubsub-v1 to v1.102.12 ([#1316](googleapis/java-asset#1316)) ([a3713fd](googleapis/java-asset@a3713fd))
* Update dependency com.google.api.grpc:proto-google-cloud-pubsub-v1 to v1.102.13 ([#1321](googleapis/java-asset#1321)) ([883b7b8](googleapis/java-asset@883b7b8))
* Update dependency com.google.api.grpc:proto-google-cloud-pubsub-v1 to v1.102.14 ([#1334](googleapis/java-asset#1334)) ([56cb4b4](googleapis/java-asset@56cb4b4))
* Update dependency com.google.api.grpc:proto-google-identity-accesscontextmanager-v1 to v1.4.1 ([#1307](googleapis/java-asset#1307)) ([b90baf7](googleapis/java-asset@b90baf7))
* Update dependency com.google.cloud:google-cloud-bigquery to v2.14.4 ([#1301](googleapis/java-asset#1301)) ([64f7ea5](googleapis/java-asset@64f7ea5))
* Update dependency com.google.cloud:google-cloud-bigquery to v2.14.6 ([#1315](googleapis/java-asset#1315)) ([fa179e2](googleapis/java-asset@fa179e2))
* Update dependency com.google.cloud:google-cloud-bigquery to v2.14.7 ([#1320](googleapis/java-asset#1320)) ([06d1a16](googleapis/java-asset@06d1a16))
* Update dependency com.google.cloud:google-cloud-bigquery to v2.15.0 ([#1326](googleapis/java-asset#1326)) ([df36595](googleapis/java-asset@df36595))
* Update dependency com.google.cloud:google-cloud-bigquery to v2.16.0 ([#1336](googleapis/java-asset#1336)) ([870779d](googleapis/java-asset@870779d))
* Update dependency com.google.cloud:google-cloud-core to v2.8.10 ([#1323](googleapis/java-asset#1323)) ([09e03b8](googleapis/java-asset@09e03b8))
* Update dependency com.google.cloud:google-cloud-core to v2.8.11 ([#1331](googleapis/java-asset#1331)) ([a112cec](googleapis/java-asset@a112cec))
* Update dependency com.google.cloud:google-cloud-core to v2.8.9 ([#1314](googleapis/java-asset#1314)) ([8edc2b8](googleapis/java-asset@8edc2b8))
* Update dependency com.google.cloud:google-cloud-pubsub to v1.120.11 ([#1298](googleapis/java-asset#1298)) ([172b34b](googleapis/java-asset@172b34b))
* Update dependency com.google.cloud:google-cloud-pubsub to v1.120.12 ([#1317](googleapis/java-asset#1317)) ([1ea636f](googleapis/java-asset@1ea636f))
* Update dependency com.google.cloud:google-cloud-pubsub to v1.120.13 ([#1322](googleapis/java-asset#1322)) ([b7522b9](googleapis/java-asset@b7522b9))
* Update dependency com.google.cloud:google-cloud-pubsub to v1.120.14 ([#1335](googleapis/java-asset#1335)) ([e9142b4](googleapis/java-asset@e9142b4))
* Update dependency com.google.cloud:google-cloud-resourcemanager to v1.5.3 ([#1318](googleapis/java-asset#1318)) ([aa3a1bb](googleapis/java-asset@aa3a1bb))
* Update dependency com.google.cloud:google-cloud-resourcemanager to v1.5.4 ([#1328](googleapis/java-asset#1328)) ([fca0ce5](googleapis/java-asset@fca0ce5))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.2 ([#1330](googleapis/java-asset#1330)) ([ccb704c](googleapis/java-asset@ccb704c))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#1340](googleapis/java-asset#1340)) ([0d87a9d](googleapis/java-asset@0d87a9d))
* Update dependency com.google.cloud:google-cloud-storage to v2.11.3 ([#1299](googleapis/java-asset#1299)) ([d59e6c6](googleapis/java-asset@d59e6c6))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the Cloud Logging API. api: pubsub Issues related to the Pub/Sub API. dependencies priority: p2 Moderately-important priority. Fix may not be included in next release. status: blocked Resolving the issue is dependent on other work. triaged for GA type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

9 participants