Quick revision
The short answer
Not in its current form. We audit what the library holds, delete the generic helpers that duplicate the JDK, Guava or Commons Lang with automated refactoring, and split the genuinely company-specific code into small modules that each have an owner and strict semantic versioning. We keep investing only in the parts that carry company knowledge, because generic helpers cost maintenance and give nothing the standard libraries do not already give.
What to remember
In this answer, we saw why internal commons libraries grow without owners and become risky dependencies of the whole fleet. We audit them into generic, company-specific and unused code, remove the generic duplicates with deprecation and automated refactoring, split the company-specific code into small owned modules, and guard those modules with semantic versioning, compatibility checks and a platform BOM. We keep investing only in the code that carries real company knowledge.
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.
Not in its current form. We audit what the library holds, delete the generic helpers that duplicate the JDK, Guava or Commons Lang with automated refactoring, and split the genuinely company-specific code into small modules that each have an owner and strict semantic versioning. We keep investing only in the parts that carry company knowledge, because generic helpers cost maintenance and give nothing the standard libraries do not already give.
Why this question is asked
Almost every company older than a few years has a library called commons, common-utils or core. It starts with good intentions: one place for a string helper, a date formatter, a retry loop and the company's tenant header. Ten years later it is a dependency of 300 services, nobody owns it, and every change to it is frightening because it reaches the whole fleet. Interviewers ask this at a senior level because the answer shows whether we can reason about cost, ownership and blast radius instead of only about code. In this answer, we will look at how such a library grows, how to audit it, how to remove the generic parts safely at scale, how to split what remains, and how to version it so a change no longer touches 300 services at once.
1How a Commons Library Grows Without an Owner
A commons library grows because adding to it is cheap and removing from it is expensive. A developer needs a null-safe string check, finds nothing in the shared library, and adds StringHelper.isEmpty. Two years later somebody else adds a CollectionHelper, then a copy of Guava's Preconditions because a team was not allowed to add Guava. Each addition is a few lines, so nobody asks whether it should exist.
The cost appears later. Every class in the library is public API, because some of the 300 services may call it. Every dependency the library pulls in, such as an old Jackson or Guava version, becomes a dependency of every service. And because the library mixes unrelated things, a change to the date helper forces a new release that every consumer has to take, even the ones that only use the tenant header. The library has a large blast radius, meaning the number of systems a single change can break, and almost no owner.
So the question is not whether shared code is good. Shared code that holds company knowledge is valuable. The question is which parts of this library are worth what they cost.
2Audit What It Contains and Who Uses It
Before deciding anything, we measure. We sort every public class by what it does. Generic helpers do something any Java program might want: string checks, collection utilities, retry loops, date formatting, a hand-written immutable list. Company-specific code encodes something only we know: how a tenant id is read from a request, how our internal events are signed, how a customer number is validated.
Then we find out which classes are actually used. Because the consumers are our own services, we can search every repository, or better, run a small static analysis over the compiled jars that records every call into the library's packages. The result is usually surprising: a few classes are used by hundreds of services, and a large part of the library is used by nobody or by one team.
| Group | Example | Classes | Decision |
|---|---|---|---|
| Generic, JDK has it | StringHelper.isBlank, ListHelper.of | 55 | Replace with JDK, then delete |
| Generic, library has it | Copied Preconditions, Joiner | 35 | Replace with Guava or Commons Lang |
| Company-specific | TenantContext, EventSigner | 30 | Move to focused, owned modules |
| Unused | Old XML helpers | 20 | Deprecate, delete next major |
With that inventory, the decisions become concrete instead of a matter of opinion. In a typical audit, we might find 140 public classes, of which 90 are generic, 30 are company-specific and 20 are unused.
3Remove the Generic Duplicates With Automated Refactoring
Generic helpers are pure cost. The JDK has caught up with most of them: String.isBlank and String.strip since Java 11, List.of and Map.of since Java 9, Objects.requireNonNullElse, records instead of hand-written value classes, and java.time instead of date helpers. Where the JDK still has a gap, Guava or Commons Lang are maintained by people who do this full time, with far more users finding the bugs.
With 300 consumers, nobody should replace these calls by hand. We first deprecate each duplicate and point at its replacement, so every build shows a warning. Then we write an automated refactoring, for example an OpenRewrite recipe, that rewrites the calls in every repository and opens a pull request. The tool parses the code properly, so it changes only real calls and keeps formatting.
Notice one detail in the example: the JDK method throws a NullPointerException on null, while the internal helper returned true. A naive search and replace would break services. That is the reason the recipe writes the explicit null check, and the reason we test each recipe on a few real services before running it across the fleet.
4Split the Company-Specific Parts Into Owned Modules
What remains after the clean-up is the part worth investing in. But it should not stay one library. We split it by purpose into small modules, for example company-tenancy, company-events and company-http-headers. Each module has a named owning team, a short README that says what belongs in it, and its own release cadence.
The reason is coupling. A service that needs the tenant header should not have to take a new version of the event signer, or the dependencies the signer brings. With focused modules, a change reaches only the services that use that module, and the owners can reason about all their consumers. A module that nobody is willing to own is a strong sign it should not exist.
5Reduce the Blast Radius With Versioning Discipline
Splitting helps, but the modules are still shared, so how they change matters. We use semantic versioning strictly: a patch release fixes bugs, a minor release adds things without breaking anything, and a major release is the only place where we remove or change public API. We enforce it with a binary compatibility checker in the build, such as japicmp or revapi, so a breaking change in a minor release fails the build instead of failing 300 services.
We also publish the modules through the platform's bill of materials, a BOM, which is a single artifact that fixes the versions of a set of libraries. Services take a new platform release and get a tested set of versions together. And we keep the modules' own dependencies minimal, so a consumer is not forced into a Jackson or Guava version it did not choose.
- Propose changeissue in the owning team's module
- Breaks public API?YesMajor version, migration recipeNoMinor or patch release
- Binary compatibility checkjapicmp or revapi in the build
- Test against pilot servicestwo or three real consumers
- Publish in the next platform BOMservices adopt with their normal upgrades
5 steps in order. Play them, or step through them one at a time.
The compatibility check turns an accidental breaking change into a failed build.
6Weighing the Cost Against the Value
So do we keep investing? We invest in the company-specific modules and stop investing in the generic part, then delete it. A useful way to make that case to leadership is to count the cost. If the library needs, say, half an engineer per year for releases, security patches of its dependencies and questions from consumers, and most of that time goes to the generic helpers, the clean-up pays for itself within a year or two. Meanwhile each JDK upgrade gets easier, because there is less code of our own to check.
There is also a rule to prevent the problem from coming back: a new class goes into a shared module only when its owning team agrees, it carries company knowledge, and no standard library already offers it. Commons libraries become a problem precisely because, without that rule, they grow without anyone deciding.
7Follow-up questions
Why not just freeze the library and leave it alone?
Freezing stops new problems but keeps the old ones. The library still pins old transitive dependencies, which keep appearing in security scans for all 300 services, and it still has to be rebuilt and tested for every JDK upgrade. Frozen code without an owner usually becomes the reason a JDK or Spring Boot upgrade stalls.
How do you convince 300 teams to take the changes?
We make the change cost them almost nothing. The automated refactoring opens the pull request, the build is already green on it, and the change ships with the normal platform BOM upgrade. Teams only review and merge. Deprecation warnings and a date for the major release give the rest a clear deadline.
8Conclusion
In this answer, we saw why internal commons libraries grow without owners and become risky dependencies of the whole fleet. We audit them into generic, company-specific and unused code, remove the generic duplicates with deprecation and automated refactoring, split the company-specific code into small owned modules, and guard those modules with semantic versioning, compatibility checks and a platform BOM. We keep investing only in the code that carries real company knowledge.
Open with
I would not keep investing in it as it is. First I would audit it: which classes are generic helpers that the JDK, Guava or Commons Lang already provide, which are genuinely company-specific, and which are unused.
Then, if they want more
I would measure actual usage across the 300 services with static analysis rather than guess. For the generic part, I would deprecate each helper, point to its replacement, and ship an automated refactoring, for example an OpenRewrite recipe, that opens pull requests in every service, taking care with differences like null handling.
Then I would delete those classes in the next major version. The company-specific part, things like tenancy or event signing, I would split into small modules, each with an owning team and its own release cadence, so a change to one only reaches the services that use it.
I would enforce semantic versioning with a binary compatibility check in the build and publish the modules through the platform BOM. Finally I would make the economics visible: how much engineering time the library costs per year and how much of that goes to code the JDK already offers.
Shared code is worth paying for only when it carries company knowledge, and every new addition should need an owner's agreement.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 11, Java 9
- 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 "Your platform team maintains an internal 'commons' library that duplicates parts of...": https://scrivio-interview-library.netlify.app/java/utility-libraries/c652a480ab/