Code Room
Code reviewHardcr-g305
Subject Retry logicLevel Senior–Staff~22 minCommon in Networking & APIs interviewsIndustries Software development

Question

Review this Java helper that retries a payment POST on any failure.

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
ChargeResult charge(ChargeRequest req) {    for (int attempt = 0; attempt < 3; attempt++) {        try {            HttpResponse<String> r = client.send(post("/charges", req), ofString());            if (r.statusCode() < 500) return parse(r.body());        } catch (IOException | InterruptedException e) {            // network blip — retry        }    }    throw new ChargeException("charge failed");}
Run or narrate your approach, then ask the coach.