Guides / Code review checklist
Java code review checklist: what to check in a Java PR
A Java code review checklist adds Java’s own traps to the usual checks: a null where the contract promises none, Optional.get() on an empty value, equals without hashCode, and state shared between threads. Each comes from a real Keycloak pull request.
The checks every language shares are on the code review checklist; this page is the Java layer, built from the 25 known issues in 10 Keycloak pull requests in our benchmark.[1]
Checked
What should a Java code review check?
A Java code review should check 14 things in four groups: null and contracts, equality, resources and threads, and data and security. Formatting is left to Checkstyle, so none of the 14 is about style.
Null and contracts
- Null contracts holdA method whose Javadoc says it never returns null must not. Keycloak’s
getSubGroupsCount()returned null in a fix meant to stop a NullPointerException.
IonWarp Code Review checks this Optionalis unwrapped safelyOptional.get()throws when empty, and its own Javadoc prefersorElseThrow().[2] Keycloak calledget()on recovery codes without a check.
IonWarp Code Review checks this- Argument checks check the right argumentKeycloak’s
AccessTokenContextranObjects.requireNonNullongrantTypetwice and never onrawTokenId.
IonWarp Code Review checks this - Wrappers call the delegate, not themselvesA Keycloak caching provider called
session.identityProviders().getById(), which is itself, instead of its delegate: endless recursion.
IonWarp Code Review checks this
Equality and values
equalsandhashCodechange togetherEqual objects must have equal hash codes,[3] or HashMap and HashSet lose entries.
IonWarp Code Review checks this- BigDecimal is compared with
compareToequalscounts scale, so 2.0 is not equal to 2.00.[4]
IonWarp Code Review checks this
Resources, errors and threads
- Resources close in try-with-resourcesStreams, connections and files close even when an exception is thrown.[5]
IonWarp Code Review checks this - Exceptions are specific and loggedCatch the exception you expect, not
RuntimeException, and never swallow one without a log line.
IonWarp Log & Errors checks this - Library code never exits the JVMKeycloak’s change called
picocli.exit(), which callsSystem.exit(), from inside a command.
IonWarp Code Review checks this - Shared state is thread-safe
SimpleDateFormatis not synchronized;[6] useDateTimeFormatter. Check-then-act on a shared map needscomputeIfAbsentor a lock.
IonWarp Code Review checks this - Concurrent tests wait for their threadsA Keycloak test flipped a flag and asserted before its reader thread finished, so it could pass by luck.
IonWarp Code Review checks this
Data, flags and security
- No query runs inside a loopJPA lazy loading inside a loop is one query per row; fetch the relation with the list, and page every list.
IonWarp API Performance checks this - Feature flags guard features, not cleanupKeycloak guarded the listener that cleans up permissions for removed roles, clients and groups with the V1 flag; with only V2 on, they were left orphaned.[1]
IonWarp Code Review checks this - SQL takes parametersUse
PreparedStatementparameters or JPA named parameters, never concatenated strings.[7]
IonWarp Security Review checks this
Which Java bugs reach real pull requests?
The Java bugs that reach real pull requests are broken null contracts, wrong arguments and thread races: the answer key for 10 Keycloak pull requests lists 25 issues a reviewer should catch, and these eight show the patterns.[1]
The fourth
Objects.requireNonNullchecksgrantTypeagain, so a nullrawTokenIdpasses.The check: Argument checks check the right argument
The cache calls
session.identityProviders().getById()instead of its delegate and re-enters itself.The check: Wrappers call the delegate, not themselves
getSubGroupsCount()returns null though the GroupModel Javadoc says it never does.The check: Null contracts hold
Optional.get()on the recovery codes credential with noisPresent()check.The check:
Optionalis unwrapped safelyThe cleanup listener checks the V1 flag, so with only V2 on, permissions for removed objects stay behind.
The check: Feature flags guard features, not cleanup
picocli.exit()callsSystem.exit()directly from a command.The check: Library code never exits the JVM
The test asserts before the reader thread finishes, so it can miss the exception it is for.
The check: Concurrent tests wait for their threads
A test catches
RuntimeExceptionwhere the code throwsIllegalArgumentException, so it passes for the wrong reason.The check: Exceptions are specific and logged
How many Java bugs do AI code reviewers catch?
AI code reviewers caught at most 15 of the 25 known Java issues in 10 Keycloak pull requests: CodeRabbit caught the most, and IonWarp caught 11. None caught them all, so the checklist stays with a person.[8][9]
| Reviewer | Caught (Keycloak) | Share | F1, all 50 PRs | False alarms, all 50 PRs |
|---|---|---|---|---|
| CodeRabbit | Caught: 15 of 25 | Share: 60% | F1, all 50 PRs: 42.1% | False alarms: 194 |
| Qodo v2 | Caught: 14 of 25 | Share: 56% | F1, all 50 PRs: 58.5% | False alarms: 79 |
| Cursor Bugbot | Caught: 12 of 25 | Share: 48% | F1, all 50 PRs: 51.4% | False alarms: 56 |
| IonWarp · DeepSeek V4.1 Flash | Caught: 11 of 25 | Share: 44% | F1, all 50 PRs: 49.2% | False alarms: 78 |
| Greptile v4.1 | Caught: 10 of 25 | Share: 40% | F1, all 50 PRs: 51.1% | False alarms: 78 |
Caught means the judge matched a reviewer’s comment to a known issue; false alarms are comments that matched none, over all 50 pull requests. Every row and PR is on the Code Review benchmark.
Which tools automate a Java code review?
Checkstyle, PMD, SpotBugs and Error Prone cover style and the bug patterns a compiler can see, so the reviewer spends the time on contracts, threads and data.
| Tool | What it checks | Checklist line |
|---|---|---|
| Checkstyle | What it checks: Style rules, such as the Google Java Style Guide[10][11] | Checklist line: None: style is off the list |
| PMD | What it checks: Common flaws such as unused variables and empty catch blocks[12] | Checklist line: Exceptions |
| SpotBugs | What it checks: Static analysis for bugs in Java code[13] | Checklist line: equals and hashCode, null |
| Error Prone | What it checks: Bug patterns, as compiler errors[14] | Checklist line: Null, Optional, equality |
| IonWarp | What it checks: Logic, callers and missing changes on each pull request | Checklist line: Contracts, delegates, flags, threads |

Is there a Java code review checklist template?
Yes, a Java code review checklist template is below: paste it into .github/pull_request_template.md under the general checklist.[15]
## Java review
- [ ] Null contracts hold; Javadoc matches
- [ ] Optional unwrapped with orElseThrow / orElse
- [ ] requireNonNull checks the right argument
- [ ] Wrappers call the delegate, not themselves
- [ ] equals and hashCode change together
- [ ] BigDecimal compared with compareTo
- [ ] Resources in try-with-resources
- [ ] Specific exceptions, logged
- [ ] No System.exit in library code
- [ ] Shared state thread-safe; no SimpleDateFormat across threads
- [ ] Concurrent tests join their threads
- [ ] No query in a loop; lists are paged
- [ ] Feature flags don't guard cleanup
- [ ] SQL uses parametersSources
Sources checked : each one says the day we read it.
- Martian on GitHub, code-review-benchmark, Core set: 50 pull requests and their answer key, revision e616e849 (MIT), read .
- Oracle, Java SE 21 API: Optional.get(), “The preferred alternative to this method is orElseThrow()”, read .
- Oracle, Java SE 21 API: Object.hashCode(), equal objects must have equal hash codes, read .
- Oracle, Java SE 21 API: BigDecimal.equals(), 2.0 is not equal to 2.00, read .
- Oracle, The Java Tutorials: the try-with-resources statement, read .
- Oracle, Java SE 21 API: SimpleDateFormat, “Date formats are not synchronized”, read .
- OWASP Cheat Sheet Series, SQL Injection Prevention Cheat Sheet, read .
- IonWarp, Code Review benchmark, pull request by pull request (release 2026-10-12), read .
- Winding Labs on GitHub, ai-code-review-benchmark: every row, pull request and verdict (CC BY 4.0), read .
- Checkstyle, Checkstyle, read .
- Google, Google Java Style Guide, read .
- PMD, PMD: an extensible multilanguage static code analyzer, read .
- SpotBugs, SpotBugs: find bugs in Java programs, read .
- Google, Error Prone, read .
- GitHub Docs, Creating a pull request template for your repository, read .

