Code Room
Code reviewHard
Question
Review this Java payment endpoint. Clients send an `Idempotency-Key` header to make charge creation safe to retry.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
public ChargeResult createCharge(String idempotencyKey, ChargeRequest req) { Optional<ChargeResult> existing = idemRepo.findByKey(idempotencyKey); if (existing.isPresent()) { return existing.get(); } ChargeResult result = processor.charge(req); idemRepo.save(idempotencyKey, result); return result;}Run or narrate your approach, then ask the coach.