Code RoomRetry swallows 5xx errors
HardPrep Room Coding #1938

Retry swallows 5xx errors

Code reviewNetworking & APIsSenior–Staff~22 min

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.

0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1ChargeResult charge(ChargeRequest req) {
2 for (int attempt = 0; attempt < 3; attempt++) {
3 try {
4 HttpResponse<String> r = client.send(post("/charges", req), ofString());
5 if (r.statusCode() < 500) return parse(r.body());
6 } catch (IOException | InterruptedException e) {
7 // network blip — retry
8 }
9 }
10 throw new ChargeException("charge failed");
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.