in src/main/java/com/googlesource/gerrit/plugins/manager/TokenReplaceOutputStream.java [51:79]
public void flush() throws IOException {
if (outBuff.size() < outLen) {
return;
}
byte[] outData = outBuff.toByteArray();
byte[] cmp = new byte[token.length];
ByteArrayOutputStream convertedData = new ByteArrayOutputStream(outData.length);
for (int i = 0; i < outData.length; i++) {
byte b = outData[i];
if (b != token[0] || (outData.length - i) < token.length) {
convertedData.write(outData, i, 1);
continue;
}
System.arraycopy(outData, i, cmp, 0, token.length);
if (Arrays.equals(cmp, token)) {
convertedData.write(replace);
i += token.length - 1;
}
}
resp.setHeader("Content-Length", "" + convertedData.size());
ServletOutputStream out = resp.getOutputStream();
out.write(convertedData.toByteArray());
out.flush();
}