Code Room
Code reviewMediumcr-g141
Subject Contract violationsLevel Mid–Senior~22 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Java endpoint that fetches a document and its collaborators.

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
@GetMapping("/docs/{id}")public Map<String, Object> getDoc(@PathVariable String id) {    Document doc = repo.findById(id).orElse(null);    Map<String, Object> resp = new HashMap<>();    resp.put("id", doc.getId());    resp.put("title", doc.getTitle());    try {        resp.put("collaborators", collabService.fetch(id));    } catch (Exception e) {        // best effort    }    return resp;}
Run or narrate your approach, then ask the coach.