Code Room
Code reviewHard
Question
Review this Java method that retries a payment charge on 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.
Learn the concepts
PaymentResult charge(String account, long cents) { for (int attempt = 0; attempt < 3; attempt++) { try { HttpResponse<String> r = client.send( HttpRequest.newBuilder(URI.create(PAY_URL)) .POST(BodyPublishers.ofString(body(account, cents))) .build(), BodyHandlers.ofString()); return parse(r); } catch (IOException e) { continue; } } throw new RuntimeException("charge failed");}Run or narrate your approach, then ask the coach.