Code Room
Code reviewHardcr-g089
Subject IdempotencyLevel Senior–Staff~30 minCommon in Networking & APIs interviewsIndustries Software development

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.

Talk through your review
Code to reviewjava
@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.