Scrivio Interview library
ConceptFoundations7 min read · updated 12 November 2026

What do you look for when reviewing a pull request in a Java service?

I first check correctness: does the change do what its description says, including edge cases and error handling? Then I check that tests cover the new behaviour and would fail without it, that the code is readable enough for the next person, that resources, threads and transactions are handled safely, and that there are no security problems such as missing validation, injection, leaked secrets or missing authorisation checks. I also look at size, because small pull requests get better reviews, and I ask for large ones to be split.

Why this question is asked

Code review is where most teams catch the bugs their tests miss and where knowledge spreads between engineers. But a review that only says 'looks good' or argues about brace placement catches nothing. Interviewers ask this at the five-year level to see whether we review with a clear sense of what matters most in a Java service. In this answer, we will look at what a review is for, then go through each thing to check in order of importance, with small examples of the problems a careful reviewer finds.

1What a Review Is For

A pull request review has three jobs. It catches defects before they reach production, it keeps the code understandable for the people who will change it next, and it spreads knowledge, so more than one person understands each part of the system. Formatting is not one of those jobs; a formatter in the build should handle it.

I start every review by reading the description and the linked ticket, so I know what the change is supposed to do. Without that, I can only check that the code is plausible, not that it is right. If the description is missing or vague, asking for it is my first comment.

What to look for in a Java service pull request
AreaQuestionTypical finding
Correctnessdoes it do what it says, in every case?empty list, null, rounding, wrong status code
Testswould the tests fail without the change?test only checks a mock was called
Readabilitycan the next person understand it?vague names, 80-line method, clever stream
Resources and concurrencyclosed, thread-safe, right transaction?mutable field in a singleton bean
Securityvalidated, authorised, no secrets?SQL built by string concatenation
Sizeis it small enough to review well?1,500 lines mixing refactor and feature

2Correctness and Error Handling

The most valuable thing a reviewer does is think about the cases the author did not. What happens with an empty list, a null value, a zero amount, a duplicate request, a timeout from a downstream service? Does an error produce the right HTTP status and a useful log line, or is it swallowed?

Java
@Service
class DiscountService {
private BigDecimal lastRate; // (1) shared mutable state in a singleton bean
public BigDecimal apply(Order order, String code) {
String sql = "select rate from promo where code = '" + code + "'"; // (2) SQL injection
lastRate = jdbc.queryForObject(sql, BigDecimal.class); // (3) unknown code -> EmptyResultDataAccessException, a 500
return order.total().multiply(lastRate); // (4) a 10% rate of 0.10 returns 10% of the total, not a discount
}
}

This short method has a problem for almost every area in the table, which is typical of real reviews. For correctness, an unknown promo code throws an exception that will likely surface as a 500 error rather than a clear 'invalid code' response, and the arithmetic returns the discount amount where the caller probably expects the discounted total. A reviewer finds these by asking 'what if?' for each input, not by reading the code line by line for style.

3Tests That Really Prove the Behaviour

For each behaviour the change adds or fixes, I look for a test, and I ask whether that test would fail if the change were reverted. A common weak test only verifies that a mock was called, which passes even when the logic is wrong. For a bug fix, the best test reproduces the bug first.

I also check that tests cover the edge cases I thought of during the correctness pass. If I worried about an unknown promo code, I want to see a test named something like rejectsUnknownPromoCode. Tests are also documentation: a reviewer who cannot understand the tests probably cannot understand the code either.

4Readability for the Next Person

Code is read far more often than it is written. I check that names say what things are, that methods do one thing, that the flow is easy to follow and that comments explain why something is done when it is not obvious, rather than repeating what the code says. A clever one-line stream that takes three minutes to understand is usually worse than a plain loop.

I phrase these comments as suggestions with a reason, and I mark which ones are blocking. 'Nit: consider renaming x to retryCount' is easy to accept; 'this is unreadable' is not.

5Resources, Concurrency and Transactions

Java services fail in production in a few recurring ways that are easy to spot in review. Resources such as streams, files and HTTP responses should be closed with try-with-resources. Spring beans are singletons by default, so any mutable field, like lastRate in our example, is shared by every request thread and becomes a race condition. Transactions should be as short as possible and should not include remote calls, because a slow HTTP call inside @Transactional holds a database connection for its whole duration.

I also look for @Transactional or @Async on private methods or on methods called from the same class, because Spring's proxies never see those calls and the annotation silently does nothing.

6Security Checks

Every change that touches input, data access or responses gets a security pass. Is user input validated, for example with Bean Validation annotations on the request object? Is SQL built with parameters rather than string concatenation? Our example's query lets a code such as ' or '1'='1 change the meaning of the SQL; the fix is a placeholder, as in jdbc.queryForObject("select rate from promo where code = ?", BigDecimal.class, code).

I also check that secrets are not in code, configuration files or logs, that personal data is not logged, and that endpoints check authorisation: not only that the user is logged in, but that this user may see this order. Missing object-level authorisation is one of the most common API vulnerabilities.

7Size: Ask for Small Pull Requests

Review quality drops sharply with size. A 100-line change gets careful attention; a 1,500-line change gets skimmed and approved. When a pull request mixes a refactoring with a feature, or touches many unrelated areas, I ask the author to split it, for example into a refactoring-only pull request and a small feature on top.

This is easier when the team agrees on it in advance, so splitting is a normal request rather than a criticism. Small, frequent pull requests also merge faster and cause fewer conflicts, so they help the author as much as the reviewer.

8Follow-up questions

How long should a review take?

For a pull request of a few hundred lines, typically 20 to 60 minutes of focused attention. Beyond about an hour, attention drops and defects slip through, which is another reason to keep changes small. A first response within a working day keeps authors unblocked.

What do you do when you disagree with the author's design?

Raise it early and as a question with a reason, ideally in a short conversation rather than a long comment thread. If the design works and the disagreement is a matter of taste, I let it go. If it has a real cost, such as a performance or maintenance risk, I explain the cost and suggest an alternative, and we involve a third person if we cannot agree.

Should the reviewer run the code?

Usually not; the CI pipeline runs the tests, and reviewers should not repeat that work. But for tricky changes, checking out the branch to try an edge case or read the code in an IDE with navigation is often faster than reasoning about a diff in the browser.

9Conclusion

In this answer, we went through what to look for when reviewing a pull request in a Java service, in order of importance: correctness including edge cases and error handling, tests that would fail without the change, readability for the next person, safe handling of resources, concurrency and transactions, security issues such as validation, injection, secrets and authorisation, and the size of the change itself, with a request to split anything too large to review well.

What to say in the interviewAbout 90 seconds aloud

Open with

I start by reading the description and ticket, so I know what the change is meant to do. Then correctness comes first: I think about the cases the author may have missed, like empty lists, nulls, duplicates, timeouts and wrong status codes, and whether errors are handled and logged rather than swallowed.

Then, if they want more

Next I check the tests: is the new behaviour covered, and would those tests fail if the change were reverted? A test that only verifies a mock was called doesn't prove much. Then readability: clear names, small methods, comments that explain why. I mark those comments as suggestions unless they're important.

In a Spring service I specifically look at resources and concurrency: try-with-resources for streams and responses, no mutable fields in singleton beans because every request thread shares them, transactions kept short without remote calls inside, and annotations like @Transactional not used on self-invoked methods where the proxy won't apply.

Security gets its own pass: input validation, parameterised SQL instead of string concatenation, no secrets or personal data in logs, and an authorisation check that this user can access this specific resource. Finally I look at size.

Small pull requests get much better reviews, so if a change is huge or mixes a refactoring with a feature, I ask the author to split it.

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 "What do you look for when reviewing a pull request in a Java service?": https://scrivio-interview-library.netlify.app/java/clean-code/f53bad45af/