Quick revision
The short answer
We standardise rather than ban or ignore. Banning Guava is impractical because many libraries depend on it transitively, so we pin one version for every service through a company BOM or platform. We discourage direct use where the JDK now covers the need, through lint rules and code review, keep the pinned version current because Guava has had security fixes, keep Guava types out of the public APIs of our internal libraries, and track usage with dependency scanning so each upgrade is predictable.
What to remember
In this answer, we chose to standardise Guava rather than ban it or leave it alone. A company BOM pins one tested version for every service and CI convergence checks keep it that way, static analysis and code review discourage direct use where the JDK now covers it, the BOM tracks recent releases because Guava has had security fixes, internal libraries keep Guava types out of their public APIs, and dependency scanning shows where every version runs, making upgrades and security responses predictable.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We standardise rather than ban or ignore. Banning Guava is impractical because many libraries depend on it transitively, so we pin one version for every service through a company BOM or platform. We discourage direct use where the JDK now covers the need, through lint rules and code review, keep the pinned version current because Guava has had security fixes, keep Guava types out of the public APIs of our internal libraries, and track usage with dependency scanning so each upgrade is predictable.
Why this question is asked
Guava is everywhere in a typical Java organisation: in our own code, in Google client libraries, in gRPC, in many other open-source libraries, often in four or five different versions across services. Each service resolves its own version by accident of its dependency tree, so a routine library upgrade can break startup with NoSuchMethodError, and nobody can say which services carry a version with a known vulnerability. Interviewers ask this as a leadership question because the answer is a policy for many teams, not a code change. In this answer, we will look at why banning and ignoring both fail, how to standardise the version, how to reduce direct use, why staying current matters, how to design internal libraries, and how to track it all.
1Why Banning and Ignoring Both Fail
Banning Guava sounds clean, but it is not something we control. Many widely used libraries depend on Guava transitively, so a service that never imports com.google.common still has Guava on its classpath. A ban would therefore apply only to our own imports, and it would push teams to copy small utilities into their own code, creating many slightly different versions of the same helpers.
Leaving it alone is worse. Each service ends up with whatever version its dependency tree produces, so the organisation runs many versions, some years old. Conflicts appear at random when a team adds a dependency, and when a security advisory is published, nobody knows quickly which services are affected. The middle path, standardising, gives us the benefits of control without fighting the ecosystem.
2Standardising the Version Through a Company BOM
A BOM, bill of materials, is a Maven POM that only lists managed versions; importing it makes those versions apply to every direct and transitive dependency. A platform team publishes a company BOM, often layered on top of the Spring Boot BOM, which pins Guava (through the Guava BOM) along with other libraries that cause frequent conflicts, such as Jackson, Netty and protobuf. Gradle projects consume the same versions as a platform.
- Service buildimports the company BOM, declares no Guava version
- Company platform BOMpins guava 33.x-jre, Jackson, Netty, protobuf
- Spring Boot BOMSpring, Jackson and many other managed versions
- Transitive requestslibraries ask for various Guava versions; overridden
4 layers, from the top down. Step through them one at a time.
One decision at the platform layer replaces a different accident in every service.
The platform team tests each new BOM release against a set of representative services before publishing, so upgrading becomes a single version change per service. Combined with a CI rule such as Maven Enforcer's dependencyConvergence, which fails when versions diverge, every service gets the same, tested Guava.
3Reducing Direct Use Where the JDK Covers It
Standardising the version does not mean encouraging more Guava. On a modern JDK, much of what services import from Guava has a standard equivalent: Optional, null checks, joining, immutable lists, file helpers. Every direct import is surface area we must keep compatible across upgrades. So we discourage those uses in new code, while keeping Guava where it adds real value, such as Multimap, RangeMap or ImmutableMap in APIs that need ordering.
We back this with tooling rather than memos: static analysis rules (Error Prone, ArchUnit or a checkstyle import rule) that flag com.google.common.base.Optional or Preconditions.checkNotNull in new code with a suggested replacement, and guidance for reviewers. Existing code changes when teams touch it; there is no need for a rewrite, and OpenRewrite recipes can automate the simple replacements when a team wants to.
4Keeping Guava Current
A standard version only helps if it is a recent one. Guava has had security fixes; for example, issues with how temporary directories and files were created with permissions that other local users could read were reported and fixed in past releases (check the advisories for exact versions). A service stuck on an old version carries those issues, and with transitive dependencies it may not even know it has Guava.
Guava releases regularly and keeps strong backward compatibility for its stable APIs, while beta APIs, marked @Beta, can change. So the platform BOM moves to a new Guava within a few weeks of a release, after its test run, and services pick it up with their regular BOM upgrade. Keeping current in small steps is far cheaper than jumping several major versions after an incident.
5Keeping Guava Out of Internal Library APIs
Internal libraries, shared clients and frameworks used by many services, deserve a special rule: do not expose Guava types in public APIs. If our shared client's method returns an ImmutableMultimap or accepts a Guava Function, every consumer must have a compatible Guava, and upgrading Guava in the library can break consumers' builds. Using JDK types (List, Map, java.util.function.Function, Optional) at the boundary keeps Guava an implementation detail.
Inside the library, Guava may still be used, and the company BOM ensures the same version everywhere. For libraries that are distributed outside the BOM's reach, shading Guava, relocating its classes into the library's own package, is a last resort; it avoids conflicts but makes the library bigger and hides vulnerabilities from scanners, so we prefer simply not exposing it.
6Tracking Usage With Dependency Scanning
To manage this across hundreds of services, we need data. Dependency scanning, such as the software bill of materials (SBOM) generated in each build, or a tool that reads the resolved dependency trees, tells us for every service which Guava version it runs, whether it is direct or transitive, and whether it is on the current BOM. Security scanners use the same data to flag known vulnerabilities.
A simple dashboard showing services by Guava version, and the trend of direct imports of discouraged APIs, makes upgrades predictable: we know which services are behind, which teams to help, and when an old version has disappeared. When the next advisory arrives, the answer to which services are affected takes minutes, not a week of searching.
| Option | What happens | Verdict |
|---|---|---|
| Ban Guava | Transitive copies remain; teams copy utilities | Impractical |
| Leave it alone | Many versions, random conflicts, unknown exposure | Risky |
| Standardise via BOM | One tested version, CI convergence checks | Chosen |
| Plus: discourage JDK-covered use | Less surface area over time | Chosen |
| Plus: no Guava in internal APIs | Consumers not forced into a version | Chosen |
7Follow-up questions
How do you roll out a company BOM to services that have never used one?
Start with a few willing teams, fix the conflicts their builds reveal, and publish the BOM with clear upgrade notes. Then make it part of the service template, so new services start with it, and offer help to existing ones. A CI check that reports, rather than fails, for services outside the BOM can turn into a failing check once most teams have moved.
What if a service really needs a different Guava version?
We allow an explicit, documented override in that service with an expiry date, and the platform team works on removing the reason, such as a library that needs updating. Exceptions should be visible in the scanning dashboard, not hidden in a build file.
Is this policy specific to Guava?
No. Guava is a good example because it is so widespread, but the same approach applies to Jackson, Netty, protobuf, logging libraries and any dependency that many libraries pull in: one tested version in the platform BOM, convergence checks, no exposure in internal APIs, and scanning to know where everything is.
8Conclusion
In this answer, we chose to standardise Guava rather than ban it or leave it alone. A company BOM pins one tested version for every service and CI convergence checks keep it that way, static analysis and code review discourage direct use where the JDK now covers it, the BOM tracks recent releases because Guava has had security fixes, internal libraries keep Guava types out of their public APIs, and dependency scanning shows where every version runs, making upgrades and security responses predictable.
Open with
I'd standardise. Banning Guava doesn't work because so many libraries bring it in transitively, so services would still have it, just without control, and teams would copy utilities around.
Then, if they want more
Leaving it alone means many versions, random NoSuchMethodError conflicts when someone adds a dependency, and no quick answer when a security advisory comes out.
So the platform team would publish a company BOM, layered on the Spring Boot BOM, that pins one tested Guava version through the Guava BOM, and every service imports it, with an Enforcer convergence rule in CI.
At the same time I'd discourage direct use where the JDK now covers it, like Optional, null checks and immutable lists, with static analysis rules and review guidance, while keeping Guava where it adds value, such as Multimap.
The BOM would track recent Guava releases, because Guava has had security fixes, for example around temporary file permissions, and small regular upgrades are cheap. For internal shared libraries, the rule is no Guava types in public APIs, so consumers aren't forced into a version.
And I'd track everything with dependency scanning and SBOMs, so we can see which services run which version and make upgrades predictable.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Guava is on the classpath of nearly every service in your organisation, often in...": https://scrivio-interview-library.netlify.app/java/utility-libraries/829bbab1d0/