-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Circular dependency in grpc-core (Gradle) #10701
Comments
This is essentially a duplicate of In truth, it isn't even a real dependency from grpc-core to grpc-util. We split grpc-util out of grpc-core and have the dependency there since users could be surprised at runtime when the round-robin LB (in grpc-util) is not present. And it'd be hard for people to debug. |
That plugin may be suffering from gradle/gradle#22850 , which was mentioned in #10576. |
To add some color to my comment in #10576 (comment), we're currently prevented from upgrading gRPC due to gradle/gradle#22850 and this cyclical dependency. This is especially problematic because it also is preventing us from upgrading Netty, because upgrading Netty to 4.1.101.Final requires a version of gRPC with #10663. It's only a matter of time before another CVE is discovered in Netty and we are forced to upgrade again, which would put us in a really difficult position. If this dependency isn't actually necessary, then I would implore you to consider removing this dependency so consumers can continue to upgrade to the latest version of gRPC. |
Can someone provide a reproduction example?
You're not able to do something like the below? dependencies {
implementation ('io.grpc:grpc-netty:1.59.0') {
exclude group: 'io.grpc', module: 'grpc-util'
}
} |
This doesn't work because The dependencies here look like:
You can workaround this by:
dependencies {
implementation ('io.grpc:grpc-netty') {
exclude group: 'io.grpc', module: 'grpc-core'
}
implementation ('io.grpc:grpc-core') {
exclude group: 'io.grpc', module: 'grpc-util'
}
} And you have to repeat process for any other dependency that transitively brings in dependencies {
implementation ('io.grpc:grpc-netty') {
exclude group: 'io.grpc', module: 'grpc-core'
}
implementation ('io.grpc:grpc-core') {
exclude group: 'io.grpc', module: 'grpc-util'
}
// Some other dependency that depends on grpc-netty
implementation ('com.example:foo') {
exclude group: 'io.grpc', module: 'grpc-netty'
}
// Some other that transitively depends on grpc-netty
implementation ('com.example:bar') {
exclude group: 'io.grpc', module: 'grpc-core'
}
} This also causes problems in tools that detect unused Gradle dependencies. The |
I've definitely excluded transitive dependencies via that approach before. Did you try it? It seems it works to me. configurations {
doesItBreak
}
dependencies {
doesItBreak('io.grpc:grpc-netty:1.59.1') {
exclude group: 'io.grpc', module: 'grpc-util'
}
}
println(configurations.doesItBreak.getResolvedConfiguration().getFirstLevelModuleDependencies().find{ true }.getAllModuleArtifacts()) Without the exclude, I do see the java.lang.StackOverflowError. |
Ah sorry, you're right. It didn't seem to be working earlier when I tried, but I must have been doing something wrong,. Trying it again and it does seem to work. |
While this helps, can we avoid this? Even if someone migrates their gradle with the fix from their side. There will be other side effects, if it is a large project. |
I suggest you also post more on gradle/gradle#22850 since changing this in gRPC would be a workaround. |
Seems we've done as much as we can for now. Once you have more info or questions, comment, and this can be reopened. |
Add the 'fake' dependency to grpc-netty instead of grpc-core. grpc-okhttp already depends on grpc-util and probably would be fine without round_robin on Android. Worksaround grpc#10857 grpc#10701
Add the 'fake' dependency to grpc-netty instead of grpc-core. grpc-okhttp already depends on grpc-util and probably would be fine without round_robin on Android. There's not actually a circular dependency, but some tools can't handle the compile vs runtime distinction. Such tools are broken, but fixes have been slow and this approach works with no real downfalls. Worksaround grpc#10857 grpc#10701
Add the 'fake' dependency to grpc-netty instead of grpc-core. grpc-okhttp already depends on grpc-util and probably would be fine without round_robin on Android. There's not actually a circular dependency, but some tools can't handle the compile vs runtime distinction. Such tools are broken, but fixes have been slow and this approach works with no real downfalls. Works around grpc#10857 grpc#10701
Add the 'fake' dependency to grpc-netty instead of grpc-core. grpc-okhttp already depends on grpc-util and probably would be fine without round_robin on Android. There's not actually a circular dependency, but some tools can't handle the compile vs runtime distinction. Such tools are broken, but fixes have been slow and this approach works with no real downfalls. Works around grpc#10576 grpc#10701
Add the 'fake' dependency to grpc-netty instead of grpc-core. grpc-okhttp already depends on grpc-util and probably would be fine without round_robin on Android. There's not actually a circular dependency, but some tools can't handle the compile vs runtime distinction. Such tools are broken, but fixes have been slow and this approach works with no real downfalls. Works around #10576 #10701
Add the 'fake' dependency to grpc-netty instead of grpc-core. grpc-okhttp already depends on grpc-util and probably would be fine without round_robin on Android. There's not actually a circular dependency, but some tools can't handle the compile vs runtime distinction. Such tools are broken, but fixes have been slow and this approach works with no real downfalls. Works around grpc#10576 grpc#10701
Add the 'fake' dependency to grpc-netty instead of grpc-core. grpc-okhttp already depends on grpc-util and probably would be fine without round_robin on Android. There's not actually a circular dependency, but some tools can't handle the compile vs runtime distinction. Such tools are broken, but fixes have been slow and this approach works with no real downfalls. Works around #10576 #10701
What version of gRPC-Java are you using?
1.59.0
What is your environment?
Android
What did you expect to see?
There shouldn't be circular dependencies in libraries. We are using google-oss-licenseplugin in our project to show the licenses of libraries we want to use. But, due to this the project is failing to build release version.
What did you see instead?
Seeing circular dependencies in grpc-core -> grpc-util -> grpc-core
Steps to reproduce the bug
Adding
grpc-core
to any library and generating dependency graph.The text was updated successfully, but these errors were encountered: