Code Room
Code reviewHardcr-g272
Subject CorrectnessLevel Senior–Staff~18 minCommon in Code quality & review · Algorithms & data structures interviewsIndustries Software development

Question

Review this Java request router that dispatches on an uppercased command keyword.

The service runs in pods whose locale is inherited from the host. QA in the US passes; a customer in Turkey reports that valid `insert`/`index` commands are rejected.

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
void dispatch(Request req) {    String cmd = req.header("X-Command");    if (cmd == null) {        reject(req);        return;    }    switch (cmd.toUpperCase()) {        case "INSERT": doInsert(req); break;        case "INDEX":  doIndex(req);  break;        case "DELETE": doDelete(req); break;        default:       reject(req);    }}
Run or narrate your approach, then ask the coach.