[Demonstration 1]

[Buggy Method]
public static void main(String[] args) throws InterruptedException {
    String query = "test";
    String[] fields = new String[3];
    fields[0] = "url";
    fields[1] = "title";
    fields[2] = "body";
    DebuggerSearchEngine dse = new StupidSearchEngine();
    String contentType = "html";
    dse.getResults(query, fields, contentType, false, "en");
    SpeedTest[] tests = new SpeedTest[Runtime.getRuntime().availableProcessors()];
    for (int i = 0; i < tests.length; i++) {
        tests[i] = new SpeedTest();
    }
    double start = System.currentTimeMillis();
    for (int i = 0; i < tests.length; i++) {
        tests[i].start();
    }
    for (int i = 0; i < tests.length; i++) {
        tests[i].join();
        ;
    }
    double stop = System.currentTimeMillis();
    double time = stop - start;
    System.out.println(time);
}

[Buggy Hunk]
System.out.println(time);

[Patch]
System.out.println(attempt*4+" query executed in : "+time);

[Demonstration 2]

[Buggy Method]
public static void saveToFile(File file, GunData data) {
    if (!file.exists())
        try {
            file.mkdir();
            file.createNewFile();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    FileOutputStream fout;
    ObjectOutputStream oos;
    try {
        fout = new FileOutputStream(file);
        oos = new ObjectOutputStream(fout);
        oos.writeObject(data);
        oos.flush();
        fout.close();
        oos.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

[Buggy Hunk]
file.mkdir();

[Patch]
new File("weapons/").mkdir();

[Demonstration 3]

[Buggy Method]
private void save() {
    BufferedWriter out = null;
    try {
        File sdCardRoot = Environment.getExternalStorageDirectory();
        if (sdCardRoot.canWrite()) {
            // Create the file name
            String format = "yyyy-MM-dd-HHmmss";
            SimpleDateFormat formatter = new SimpleDateFormat(format);
            Date now = new Date();
            File dir = new File(sdCardRoot, SD_CARD_MISC_DIR);
            if (dir.exists() && dir.isFile()) {
                Utils.errMsg(this, "Cannot create directory: " + dir + "\nA file with that name exists.");
                return;
            }
            if (!dir.exists()) {
                Log.d(TAG, this.getClass().getSimpleName() + ": create: dir=" + dir.getPath());
                boolean res = dir.mkdir();
                if (!res) {
                    Utils.errMsg(this, "Cannot create directory: " + dir);
                    return;
                }
            }
            String fileName = String.format(SAVE_FILE_NAME, formatter.format(now), now.getTime());
            File file = new File(dir, fileName);
            FileWriter writer = new FileWriter(file);
            out = new BufferedWriter(writer);
            out.write("id\t" + "date\t" + "number\t" + "type\t" + "duration\t" + "name\n");
            // Get the database again to avoid traversing the ListView,
            // which only has visible items
            Cursor cursor = null;
            try {
                // Get a cursor
                String[] desiredColumns = { COL_ID, COL_NUMBER, COL_DATE, COL_DURATION, COL_TYPE, COL_NAME };
                cursor = getContentResolver().query(getUri(), desiredColumns, mFilters[filter].selection, null, SORT_ORDERSs[mSortOrder].sortOrder);
                int indexId = cursor.getColumnIndex(COL_ID);
                int indexDate = cursor.getColumnIndex(COL_DATE);
                int indexNumber = cursor.getColumnIndex(COL_NUMBER);
                int indexDuration = cursor.getColumnIndex(COL_DURATION);
                int indexType = cursor.getColumnIndex(COL_TYPE);
                int indexName = cursor.getColumnIndex(COL_NAME);
                // Loop over items
                cursor.moveToFirst();
                while (cursor.isAfterLast() == false) {
                    String id = cursor.getString(indexId);
                    String number = "<Number NA>";
                    if (indexNumber > -1) {
                        number = cursor.getString(indexNumber);
                    }
                    Long dateNum = -1L;
                    if (indexDate > -1) {
                        dateNum = cursor.getLong(indexDate);
                    }
                    String duration = "<Duration NA>";
                    if (indexDuration > -1) {
                        duration = cursor.getString(indexDuration);
                    }
                    int type = -1;
                    if (indexType > -1) {
                        type = cursor.getInt(indexType);
                    }
                    String name = "Unknown";
                    if (indexName > -1) {
                        name = cursor.getString(indexName);
                        if (name == null) {
                            name = "Unknown";
                        }
                    }
                    out.write(id + "\t" + formatDate(MessageUtils.mediumFormatter, dateNum) + "\t" + MessageUtils.formatAddress(number) + "\t" + formatType(type) + "\t" + formatDuration(duration) + "\t" + name + "\n");
                    cursor.moveToNext();
                }
            } catch (Exception ex) {
                out.write("Error finding calls\n" + ex.getMessage());
            } finally {
                if (cursor != null) {
                    cursor.close();
                }
            }
            Utils.infoMsg(this, "Wrote " + file.getPath());
        } else {
            Utils.errMsg(this, "Cannot write to SD card");
            return;
        }
    } catch (Exception ex) {
        Utils.excMsg(this, "Error saving to SD card", ex);
    } finally {
        try {
            out.close();
        } catch (Exception ex) {
            // Do nothing
        }
    }
}

[Buggy Hunk]
SORT_ORDERSs[mSortOrder].sortOrder);

[Patch]
sortOrders[mSortOrder].sortOrder);