Repository navigation
[JENKINS-36779] Upgrade Guava or properly isolate core Guava dependency from plugins #17355
Description
For a while, we could use a newer version of Guava in a plugin than in core - see, for example, jclouds plugin version 2.5, which uses Mask-Classes on the manifestEntries for maven-hpi-plugin to mask com.google.common. That worked fine with core's Guava 11.0 and jclouds' Guava 14.0.1. But moving to a newer jclouds version, with a dependency on Guava 15.0, made things go horribly wrong. I don't remember off the top of my head exactly what went wrong, but I'll reproduce that and add the relevant logs as attachments here. What finally fixed things there was moving to a shaded Guava jar and depending on that - see the state of the code as of here.
Given that context...I know people are still hitting problems due to Guava incompatibilities - anything with a newer Guava version could fail horribly due to API methods that have since been removed being called by Jenkins itself and borking due to the newer Guava being in the classpath. So something needs to be done here - either better isolation of Guava (either as part of a general improvement to classloader isolation or possibly a more Guava-specific solution) or upgrading Guava...though upgrading Guava means breaking plugins that use/depend on Guava. So...not simple. But some solution is needed eventually.
Originally reported by
abayer, imported from: Upgrade Guava or properly isolate core Guava dependency from plugins
- assignee: basil
- status: Closed
- priority: Major
- component(s): core
- resolution: Fixed
- resolved: 2021-11-09T13:46:37+00:00
- votes: 4
- watchers: 11
- imported: 2025-11-24
Raw content of original issue
For a while, we could use a newer version of Guava in a plugin than in core - see, for example, jclouds plugin version 2.5, which uses Mask-Classes on the manifestEntries for maven-hpi-plugin to mask com.google.common. That worked fine with core's Guava 11.0 and jclouds' Guava 14.0.1. But moving to a newer jclouds version, with a dependency on Guava 15.0, made things go horribly wrong. I don't remember off the top of my head exactly what went wrong, but I'll reproduce that and add the relevant logs as attachments here. What finally fixed things there was moving to a shaded Guava jar and depending on that - see the state of the code as of here.
Given that context...I know people are still hitting problems due to Guava incompatibilities - anything with a newer Guava version could fail horribly due to API methods that have since been removed being called by Jenkins itself and borking due to the newer Guava being in the classpath. So something needs to be done here - either better isolation of Guava (either as part of a general improvement to classloader isolation or possibly a more Guava-specific solution) or upgrading Guava...though upgrading Guava means breaking plugins that use/depend on Guava. So...not simple. But some solution is needed eventually.
Activity
jenkins-infra-bot commentedon Jul 18, 2016
Remote link associated with this issue:
jenkins-infra-bot commentedon Jul 19, 2016
Raw content of original comment:
Probably best to tackle JENKINS-30685.
jenkins-infra-bot commentedon Jul 10, 2019
Raw content of original comment:
See artifact-manager-s3 #83 for an example (again based on the jclouds library, but not using jclouds-plugin) of a case where the bundled Guava made it impossible to do an otherwise straightforward refactoring.
jenkins-infra-bot commentedon Jan 8, 2021
Raw content of original comment:
FYI the requirement of an outdated version of Guava (v11) blocks the usage of gRPC (requires Guava v20) and transitively blocks the usage of the OpenTelemetry SDK (1) to instrument and observe Jenkins and its jobs.
(1) the OpenTelemetry SDK requires gRPC for both the official OpenTelemetry Protocol exporter and the Jaeger exporter
Error message happening with all the grpc libs: grpc-okhttp, grpc-netty and grpc-shded-netty:
java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, char, java.lang.Object)' at io.grpc.Metadata$Key.validateName(Metadata.java:742) at io.grpc.Metadata$Key.(Metadata.java:750) at io.grpc.Metadata$Key.(Metadata.java:668) at io.grpc.Metadata$AsciiKey.(Metadata.java:959) at io.grpc.Metadata$AsciiKey.(Metadata.java:954) at io.grpc.Metadata$Key.of(Metadata.java:705) at io.grpc.Metadata$Key.of(Metadata.java:701) at io.grpc.internal.GrpcUtil.(GrpcUtil.java:81) at io.grpc.netty.shaded.io.grpc.netty.Utils.(Utils.java:77) at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.(NettyChannelBuilder.java:79) at io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider.builderForTarget(NettyChannelProvider.java:42) at io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider.builderForTarget(NettyChannelProvider.java:23) at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:76) at io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder.build(OtlpGrpcSpanExporterBuilder.java:105)See https://guava.dev/releases/20.0/api/docs/com/google/common/base/Preconditions.html#checkArgument-boolean-java.lang.String-char-java.lang.Object-
jenkins-infra-bot commentedon Jan 8, 2021
Raw content of original comment:
As shown in artifact-manager-s3, it is possible to use a newer Guava version from a plugin, but it is not straightforward.
jenkins-infra-bot commentedon Jan 9, 2021
Raw content of original comment:
Thanks jglick, your solution works. My pom.xml includes:
com.google.guava guava 20.0 ... org.jenkins-ci.tools maven-hpi-plugin com.google.common.jenkins-infra-bot commentedon Jun 25, 2021
Raw content of original comment:
using a newer Guice using similar tricks however has shown to be a problem ->
JENKINS-65757jenkins-infra-bot commentedon Oct 26, 2021
Raw content of original comment:
basil I think this can be In Review?
jenkins-infra-bot commentedon Oct 26, 2021
basil:
Raw content of original comment:
Indeed it can.
jenkins-infra-bot commentedon Nov 24, 2025
[Original
is_duplicated_byfrom Jira: JENKINS-51704]