Source:
<code>protected void service(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { final String path_info = req.getPathInfo(); if (req.getPathInfo() == null && (req.getQueryString() == null || req.getQueryString().isEmpty())) { rsp.sendRedirect(req.getContextPath() + "/"); return; } final Map<String, String> params = getParameters(req); String name = params.get("p"); if ((name == null || name.isEmpty()) && path_info != null) { String[] path_info_parts = req.getPathInfo().split("/"); <START> String new_name = ""; <END> for (int i = 1; i < path_info_parts.length; i++) { if (i != 1) new_name += '/'; new_name += path_info_parts[i]; if (new_name.endsWith(".git")) break; } if (new_name.endsWith(".git")) name = new_name; } if (name == null || !name.endsWith(".git")) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } name = name.substring(0, name.length() - 4); final Project.NameKey nameKey = new Project.NameKey(name); final ProjectControl project; try { project = projectControl.validateFor(nameKey); if (!project.allRefsAreVisible()) { throw new NoSuchProjectException(nameKey); } } catch (NoSuchProjectException e) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } final Repository repo; try { repo = repoManager.openRepository(nameKey); } catch (RepositoryNotFoundException e) { getServletContext().log("Cannot open repository", e); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } try { rsp.setHeader("Expires", "Fri, 01 Jan 1980 00:00:00 GMT"); rsp.setHeader("Pragma", "no-cache"); rsp.setHeader("Cache-Control", "no-cache, must-revalidate"); exec(req, rsp, project, repo); } finally { repo.close(); } }</code><technical_language>I prefer a StringBuilder +=</technical_language>

Target:
protected void service(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { final String path_info = req.getPathInfo(); if (req.getPathInfo() == null && (req.getQueryString() == null || req.getQueryString().isEmpty())) { rsp.sendRedirect(req.getContextPath() + "/"); return; } final Map<String, String> params = getParameters(req); String name = params.get("p"); if ((name == null || name.isEmpty()) && path_info != null) { String[] path_info_parts = req.getPathInfo().split("/"); StringBuffer new_name_buf = new StringBuffer(); for (int i = 1; i < path_info_parts.length; i++) { if (i != 1) { new_name_buf.append('/'); } new_name_buf.append(path_info_parts[i]); if (path_info_parts[i].endsWith(".git")) { break; } } name = new_name_buf.toString(); } if (name == null || !name.endsWith(".git")) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } name = name.substring(0, name.length() - 4); final Project.NameKey nameKey = new Project.NameKey(name); final ProjectControl project; try { project = projectControl.validateFor(nameKey); if (!project.allRefsAreVisible()) { throw new NoSuchProjectException(nameKey); } } catch (NoSuchProjectException e) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } final Repository repo; try { repo = repoManager.openRepository(nameKey); } catch (RepositoryNotFoundException e) { getServletContext().log("Cannot open repository", e); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } try { rsp.setHeader("Expires", "Fri, 01 Jan 1980 00:00:00 GMT"); rsp.setHeader("Pragma", "no-cache"); rsp.setHeader("Cache-Control", "no-cache, must-revalidate"); exec(req, rsp, project, repo); } finally { repo.close(); } }