Code Room
Code reviewHard
Question
Review this Java idempotent-order endpoint.
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
@PostMapping("/orders")public Order create(@RequestBody OrderReq req, @RequestHeader("Idempotency-Key") String key) { Order existing = repo.findByIdempotencyKey(key); if (existing != null) { return existing; } Order order = new Order(req); order.setIdempotencyKey(key); repo.save(order); paymentService.charge(order); return order;}Run or narrate your approach, then ask the coach.