[Demonstration 1]

[Buggy Method]
private List<Record> groupRecordsByField(String groupbyfield, List<Record> records, String... calFields) {
    BigDecimal[] countall = new BigDecimal[calFields.length];
    BigDecimal[] count = new BigDecimal[calFields.length];
    for (int i = 0; i < calFields.length; i++) {
        countall[i] = new BigDecimal(0);
        count[i] = new BigDecimal(0);
    }
    Map<String, List<Record>> groupmap = new LinkedHashMap<String, List<Record>>();
    for (Record record : records) {
        String splitkey = record.getStr(groupbyfield) == null ? "其他" : record.getStr(groupbyfield);
        if (groupmap.containsKey(splitkey)) {
            groupmap.get(splitkey).add(record);
        } else {
            List<Record> tempRecords = new ArrayList<>();
            tempRecords.add(record);
            groupmap.put(splitkey, tempRecords);
        }
    }
    for (String key : groupmap.keySet()) {
        for (int i = 0; i < calFields.length; i++) {
            count[i] = new BigDecimal(0);
        }
        for (Record record : groupmap.get(key)) {
            for (int index = 0; index < calFields.length; index++) {
                BigDecimal value = record.getBigDecimal(calFields[index]) == null ? new BigDecimal(0) : record.getBigDecimal(calFields[index]);
                count[index] = count[index].add(value);
                countall[index] = countall[index].add(value);
            }
        }
        Record grouprecord = new Record();
        grouprecord.set(groupbyfield, key);
        for (int j = 0; j < count.length; j++) {
            grouprecord.set(calFields[j], count[j]);
        }
        grouprecord.set("isgroup", true);
        groupmap.get(key).add(0, grouprecord);
    }
    List<Record> result = new ArrayList<Record>();
    for (String key : groupmap.keySet()) {
        result.addAll(groupmap.get(key));
    }
    Record totalrecord = new Record();
    for (int j = 0; j < countall.length; j++) {
        totalrecord.set(calFields[j], countall[j]);
    }
    totalrecord.set(groupbyfield, "总计");
    totalrecord.set("istotal", true);
    result.add(0, totalrecord);
    return result;
}

[Buggy Hunk]
List<Record> tempRecords = new ArrayList<>() ;

[Patch]
List<Record> tempRecords = new ArrayList<Record>() ;

[Demonstration 2]

[Buggy Method]
private void loadConfig() throws Exception {
    File config = new File(this.path + File.separator + "app.config");
    if (!config.exists())
        throw new Exception("No App Config");
    FileReader reader = null;
    Properties props = new Properties();
    try {
        reader = new FileReader(config);
        props.load(reader);
    } catch (IOException e) {
        throw new Exception("App Config error");
    } finally {
        try {
            if (reader != null)
                reader.close();
        } catch (IOException e) {
            Logger.get().error(e);
        }
    }
    this.name = props.getProperty("name");
    this.author = props.getProperty("author");
    this.description = props.getProperty("description");
    this.version = props.getProperty("version");
    this.state = props.getProperty("activeOnLoad").equals("true");
}

[Buggy Hunk]
private void loadConfig() throws Exception {

[Patch]
public void loadConfig() throws Exception {

[Demonstration 3]

[Buggy Method]
public void open() throws IOException, GeneralSecurityException {
    if (!closed) {
        throw new IOException("Try to open non channel for a non-closed closed.");
    }
    connect();
}

[Buggy Hunk]
throw new IOException("Try to open non channel for a non-closed closed.");

[Patch]
throw new ChromeCastException("Channel already oppened.");