[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]
public JsonObject getStats(String componentCode) throws IOException {
    // Get json file with materials' stats
    URL jsonUrl = Material.class.getClassLoader().getResource("json/resource_stats_" + LocaleUtil.getLanguage() + ".json");
    if (jsonUrl == null) {
        LOGGER.error("Could not find json file with all materials' stats.");
        return null;
    }
    JsonReader jsonReader = new JsonReader(new InputStreamReader(jsonUrl.openStream()));
    // Return JsonObject containing stats for the given material and component
    Gson gson = new Gson();
    Type mapOfMapsType = new TypeToken<Map<String, Map<String, Map<String, JsonObject>>>>() {
    }.getType();
    Map<String, Map<String, Map<String, JsonObject>>> map = gson.fromJson(jsonReader, mapOfMapsType);
    return map.get(this.id).get("stats").get(componentCode);
}

[Buggy Hunk]
JsonReader jsonReader = new JsonReader(new InputStreamReader(jsonUrl.openStream()));

[Patch]
JsonReader jsonReader = new JsonReader(new InputStreamReader(jsonUrl.openStream(), "UTF-8"));

[Demonstration 3]

[Buggy Method]
private Map<String, String> splitURL(String requestPath) throws MalformedURLException {
    // Remove protocol from URL
    requestPath = requestPath.replaceFirst("http://|https://", "");
    // Extract domain and extra path
    String domain, extraPath;
    int slashIndex = requestPath.indexOf('/');
    // Support for URLs with queries that follow right after <host> without a slash /
    int queryIndex = requestPath.indexOf('?');
    if (queryIndex > -1 && queryIndex < slashIndex) {
        slashIndex = queryIndex;
    }
    if (slashIndex < 1 || slashIndex == requestPath.length()) {
        domain = requestPath;
        extraPath = "";
    } else {
        domain = requestPath.substring(0, slashIndex);
        extraPath = requestPath.substring(slashIndex + 1, requestPath.length());
    }
    Map<String, String> splitMap = new HashMap<String, String>();
    splitMap.put("domain", domain);
    splitMap.put("extraPath", extraPath);
    return splitMap;
}

[Buggy Hunk]
private Map<String, String> splitURL(String requestPath) throws MalformedURLException {

[Patch]
protected Map<String, String> splitURL(String requestPath) throws MalformedURLException {