Video in progress
When you review Spring code, which mistakes do you look for first?
The things that silently fail to work: @Transactional/@Async/@Cacheable with the proxy bypassed, wrong transaction boundaries (an external call inside), N+1 and unbounded queries, state in a singleton, external calls without timeouts, security (IDOR, open endpoints, secrets in logs), and missing idempotency where there's a retry.
📖 Answer
Ordered by impact:
Security:
/api/orders/{id}: is it checked that the order belongs to the current user (IDOR)?- a new
permitAllorcsrf().disable(): is there a reason? - an entity coming in directly as
@RequestBody: mass assignment; - are tokens, passwords, card numbers or PII ending up in logs?
- string concatenation in a native query: SQL injection.
Data integrity:
@Transactionalon a self-invocation or a private method;- an HTTP call or sending an email inside a transaction;
- a swallowed exception: the transaction commits anyway;
- "read, check, write" without a lock or an atomic UPDATE;
- an event or message sent before the commit.
Performance:
- a repository call or lazy association inside a loop (N+1);
findAll()without pagination;- is there an index for the new query's column?
new ObjectMapper()/RestClienton every call.
Resilience:
- is there a timeout on the external call;
- there's a retry: is the operation idempotent?
@Async/@Scheduled: are errors visible, and does it avoid running twice on multiple instances?- an unbounded cache or queue.
Design:
- request-specific state in a singleton bean;
- field injection, a class with 10+ dependencies;
- HTTP concepts in the service layer (
ResponseEntity).
In a good review you don't just write "wrong": you write why it's dangerous and how to verify it, with a test or a concrete scenario.
Sign up to mark studied questions and save your progress.