[Demonstration 1]

[Buggy Method]
String tryClangFormat(String code) {
    Process process = null;
    try {
        process = Runtime.getRuntime().exec(CLANG_FORMAT);
        final OutputStream stdin = process.getOutputStream();
        // stdout must be final for the nested object byteSource to return it.
        final InputStream stdout = process.getInputStream();
        // Write TypeScript code to stdin of the process
        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin))) {
            writer.write(code);
            writer.close();
        }
        return readStream(stdout);
    } catch (IOException e) {
        System.err.println("clang-format has failed to execute: " + e.getMessage());
        return code;
    } finally {
        if (process != null) {
            try {
                System.err.println(readStream(process.getErrorStream()));
            } catch (@SuppressWarnings("unused") IOException ignored) {
                // Ignored.
            }
            // TODO(renez): Use .waitFor(n, TimeUnit.SECONDS) and .destroyForcibly() once we moved to
            // Java 8.
            process.destroy();
        }
    }
}

[Buggy Hunk]
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin)); ) {

[Patch]
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin, UTF_8)); ) {

[Demonstration 2]

[Buggy Method]
@Override
public Void visitLocal(String name, AST value) {
    if (functionScope) {
        int localOrdinal = locals.size();
        locals.add(name);
        visitAsExpression(value);
        if (asExpression)
            emit(Instruction.Factory.dup);
        emit(Instruction.Factory.storeVar(localOrdinal));
    } else {
        if (asExpression)
            emitLoadSelf();
        else
            implicitEnvironmentAtRoot.accept(this);
        visitAsExpression(value);
        if (asExpression)
            emit(Instruction.Factory.dupx1);
        emit(Instruction.Factory.store(name));
    }
    return null;
}

[Buggy Hunk]
emit(Instruction.Factory.dupx1);

[Patch]
emit(Instruction.Factory.dupx1down);

[Demonstration 3]

[Buggy Method]
public UploadRequest withDocStrings(List<String> docStrings) throws InvalidRequestException {
    this.docs = Lists.newArrayListWithCapacity(docs.size());
    for (String s : docStrings) {
        try {
            JsonNode json = Document.Reader.readValue(s);
            this.docs.add(json);
        } catch (Exception e) {
            throw new InvalidRequestException("Document is in invalid JSON format", e);
        }
    }
    return this;
}

[Buggy Hunk]
this.docs = Lists.newArrayListWithCapacity(docs.size());

[Patch]
this.docs = Lists.newArrayListWithCapacity(docStrings.size());