Scrivio Interview library
DesignIntermediate6 min read · updated 12 November 2026

How would you keep deprecation warnings at zero across a large codebase without blocking developers?

I would make deprecations visible and stop new ones, without failing builds on old ones: report the warning count in CI and track it over time, fail a build only when changed code adds a new deprecation, fix common cases automatically with recipes, and plan a small amount of upgrade time every sprint so the existing count falls steadily to zero.

Why this question is asked

A large codebase can easily carry thousands of deprecation warnings. If we make them all errors tomorrow, every team is blocked and someone turns the rule off within a week. If we ignore them, the next major upgrade becomes a crisis. Interviewers ask this design question to see whether we can find the middle path: a system that keeps the number heading to zero while developers keep shipping. In this answer, we will see why both extremes fail, then build the system in four parts: measuring the count, a ratchet that blocks only new deprecations, automated fixes, and a steady time budget.

1Why Both Extremes Fail

A deprecation warning tells us an API will be removed in a later release. In Spring, what one major deprecates, the next major removes. So the warnings are real future work, and the count is a fair measure of how far we are from being ready for the next upgrade.

Turning on -Werror, which makes every warning a compile error, across a codebase with 3,000 warnings stops all feature work until they are fixed. In practice teams add suppressions or disable the flag, and we end up with less information than before. Ignoring warnings fails the other way: the count grows with each release, nobody owns it, and the cost arrives all at once when the old API disappears.

The design goal, then, is to stop the count from growing, make it shrink at a predictable rate, and never block a developer for work they did not cause.

2Part 1: Report Warnings and Track the Count

First we need the data. Every build compiles with -Xlint:deprecation and -Xlint:removal so that the compiler lists each use with file and line. A small CI step parses the compiler output, counts the warnings per module and per deprecated API, and sends the numbers to a metrics store or a simple dashboard.

Tracking the count over time is what turns warnings into a plan. A chart showing 3,000 warnings falling to 2,400 over a quarter tells everyone that the work is happening and when it will finish. Grouping by API shows where a single recipe would remove hundreds of warnings at once.

YAML
# CI step after compilation (simplified)
grep -E "warning: \[(deprecation|removal)\]" build.log | wc -l # 2412
grep -oE "\[(deprecation|removal)\] [A-Za-z.]+" build.log | sort | uniq -c | sort -rn | head -3
# 610 [removal] MockBean
# 205 [deprecation] RestTemplateBuilder
# 88 [deprecation] setConnectTimeout

3Part 2: Fail Only on New Deprecations in Changed Code

The key idea is a ratchet: a rule that lets the number go down but never up. On each pull request, CI compares the warnings in the files the change touches with the warnings in the same files on the main branch. If the change adds a deprecated call, the build fails with the file, the line and the replacement from the Javadoc. If the change leaves old warnings alone, it passes.

This rule is fair to developers, because they are only stopped by their own new code, which they can fix in minutes while it is fresh. It also gradually raises the quality of touched files, because many teams fix the old warnings in a file they are already editing. Some static analysis tools support this directly as a baseline or new code mode; a small script comparing two lists of warnings works too.

Step throughThe deprecation ratchet on a pull request
  1. Compile with -Xlint:deprecation and removalcollect warnings per file
  2. Compare with main for the changed filessame file, same API
  3. New deprecated use added?
    YesFail with file, line and replacementNoPass
  4. Record the total countdashboard shows the trend

4 steps in order. Play them, or step through them one at a time.

Old warnings never block; new ones never get in.

4Part 3: Fix Common Cases Automatically

Most warnings come from a few APIs used many times, such as a deprecated test annotation used in hundreds of tests. Fixing those by hand is slow and boring. OpenRewrite, a tool that rewrites source code with recipes, has recipes for many Spring and Boot deprecations, and we can write our own for internal APIs.

I would run a recipe across all repositories as one automated pull request per repository, with the tests deciding whether it merges. One run of a recipe for @MockBean to @MockitoBean can remove several hundred warnings in an afternoon. The remaining warnings are the ones that need thought, and those are the ones we want people to spend time on.

XML
<!-- Maven: apply a recipe from the command line, dry run first -->
mvn -U org.openrewrite.maven:rewrite-maven-plugin:dryRun \
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:RELEASE \
-Drewrite.activeRecipes=org.openrewrite.java.spring.boot3.ReplaceMockBeanAndSpyBean
# writes target/rewrite/rewrite.patch: 214 files changed
# check your version of rewrite-spring for the exact recipe name

5Part 4: Plan Time Every Sprint

A ratchet stops growth and recipes remove the bulk, but the hard cases need people. I would reserve a small, fixed amount of capacity in every team's sprint for upgrade work, for example ten percent, and make the deprecation count part of the definition of a healthy service alongside test coverage and security findings.

With numbers, this is predictable. A team with 300 warnings, where recipes remove 200, has 100 left. At ten a sprint, it reaches zero in ten sprints, well before the next major. The dashboard shows which teams are on track, and those falling behind get help rather than blame, because it is often a sign of a hard library dependency.

How one team's count falls
MonthWarningsWhat happened
January300baseline measured, ratchet turned on
February100OpenRewrite recipe for test mocks merged
April60about ten fixed per sprint
June0last ones fixed; -Werror enabled for this module

6Follow-up questions

Should we ever turn deprecations into errors everywhere?

Once a module reaches zero, yes. Enabling -Werror for deprecations in that module keeps it at zero at no extra cost. Do it module by module as they reach zero, never for the whole codebase while warnings remain.

What about deprecations we cannot fix yet?

Suppress them locally with @SuppressWarnings and a comment that names the reason or the issue, such as a library that has no replacement yet. The suppression is counted separately on the dashboard, so it is not forgotten before the upgrade.

How do you handle deprecated configuration properties?

The compiler does not see them, so add a check that runs the properties migrator in a staging environment, or a search of configuration files for known old keys, and include those findings in the same dashboard.

7Conclusion

In this answer, we built a system that keeps deprecation warnings heading to zero without blocking developers. We report and track the count in CI, use a ratchet that fails builds only when changed code adds a new deprecation, remove common warnings with OpenRewrite recipes, and plan a fixed amount of time each sprint for the rest, enabling -Werror module by module once each reaches zero.

What to say in the interviewAbout 70 seconds aloud

Open with

I would treat it as a ratchet rather than a gate. Turning every deprecation into an error at once blocks all teams and usually ends with the rule disabled, and ignoring them makes the next major a crisis.

Then, if they want more

First, every build compiles with -Xlint:deprecation and -Xlint:removal, and CI counts the warnings per module and per API and sends them to a dashboard, so we can see the trend and where one fix removes many warnings.

Second, on each pull request, CI compares the warnings in the changed files with main and fails only if the change adds a new deprecated use, showing the file, line and replacement. Developers are never blocked by old debt, and new debt cannot get in.

Third, the bulk is fixed by automation: OpenRewrite recipes, for example @MockBean to @MockitoBean, as one automated pull request per repository with the tests deciding. Fourth, a small fixed share of each sprint, say ten percent, goes to the remaining hard cases, and the count is part of service health.

When a module reaches zero, I turn on -Werror for deprecations there so it stays at zero.

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 documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Boot reference
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 "How would you keep deprecation warnings at zero across a large codebase without blocking...": https://scrivio-interview-library.netlify.app/spring-boot/boot-migrations/1754299880/