Code RoomHTTP client ignores read timeout
MediumPrep Room Coding #2130

HTTP client ignores read timeout

Code reviewNetworking & APIsMid–Senior~16 min

Review this Java HTTP client config used for all calls to a slow third-party API.

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 16 min
Mark a line and say what kind of problem it is.0 findings
1OkHttpClient client = new OkHttpClient.Builder()
2 .connectTimeout(2, TimeUnit.SECONDS)
3 .build();
4 
5String fetch(String url) throws IOException {
6 try (Response r = client.newCall(new Request.Builder().url(url).build()).execute()) {
7 return r.body().string();
8 }
9}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.