Code Room
Code reviewHardcr-g494
Subject IdempotencyLevel Senior–Staff~20 minCommon in Networking & APIs interviewsIndustries Software development, Technology

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.

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