[Demonstration 1]

[Buggy Method]
@Override
public void onClick(View v) {
    PreferanceUtil preferanceUtil = new PreferanceUtil(mContext);
    preferanceUtil.setCardDetail(mCard);
    SingletonClass.sharedInstance().setCard(mCard);
    Intent intent = new Intent(getActivity(), HomeActivity.class);
    intent.putExtra("ActivityName", "Splash");
    startActivity(intent);
    //getActivity().overridePendingTransition(R.anim.slide_in_right,
    //R.anim.slide_out_right);
    //getActivity().finish();
}

[Buggy Hunk]
PreferanceUtil preferanceUtil = new PreferanceUtil(mContext);

[Patch]
PreferanceUtil preferanceUtil = new PreferanceUtil(getActivity());

[Demonstration 2]

[Buggy Method]
private Map<Integer, Map<Integer, Double>> getPrFromFiles(int fileIndex) {
    Map<Integer, Map<Integer, Double>> map = Maps.newHashMap();
    FileReader fileReader = null;
    try {
        String line = null;
        fileReader = new FileReader(new File("file/calVotes/votes" + fileIndex));
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        while ((line = bufferedReader.readLine()) != null) {
            // 0@0@0.5@0.5
            String[] str = line.split("@");
            if (str.length < 2) {
                throw new RuntimeException("vote length at least for 2");
            }
            for (int i = 1; i < str.length; i++) {
                if (map.containsKey(Integer.parseInt(str[0]))) {
                    map.get(Integer.parseInt(str[0])).put(Integer.parseInt(str[i].split(":")[0]), Double.parseDouble(str[i].split(":")[1]));
                } else {
                    Map<Integer, Double> mapPrs = Maps.newHashMap();
                    mapPrs.put(Integer.parseInt(str[i].split(":")[0]), Double.parseDouble(str[i].split(":")[1]));
                    map.put(Integer.parseInt(str[0]), mapPrs);
                }
            }
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (fileReader != null) {
                fileReader.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return map;
}

[Buggy Hunk]
fileReader = new FileReader(new File("file/calVotes/votes"+fileIndex));

[Patch]
fileReader = new FileReader(new File(CALVOTE_FILE+fileIndex));

[Demonstration 3]

[Buggy Method]
public static void publishApk(App app) {
    try {
        if (Strings.isNullOrEmpty(app.getAppContext().getApkPath())) {
            throw new UnexpectedException("apkPath cannot be null or empty!");
        }
        if (app.getAppContext().getTrackType() == null) {
            throw new UnexpectedException("trackType cannot be null or empty!");
        }
        // Create the API service.
        AndroidPublisher service = init(app.getAppContext());
        Edits edits = service.edits();
        // Create a new edit to make changes.
        Insert editRequest = edits.insert(app.getApplicationId(), null);
        AppEdit edit = editRequest.execute();
        String editId = edit.getId();
        System.out.println(String.format("Created edit with id: %s", editId));
        // Upload new apk to developer console
        AbstractInputStreamContent apkFile = new FileContent(MIME_TYPE_APK, new File(app.getAppContext().getApkPath()));
        Upload uploadRequest = edits.apks().upload(app.getApplicationId(), editId, apkFile);
        Apk apk = uploadRequest.execute();
        System.out.println(String.format("Version code %d has been uploaded", apk.getVersionCode()));
        // Remove any previous alpha or beta
        if (app.getAppContext().getTrackType().equals(TrackType.ALPHA) || app.getAppContext().getTrackType().equals(TrackType.BETA)) {
            Track track = getTrack(app, edits, editId);
            if (track != null && !track.getVersionCodes().isEmpty()) {
                Boolean replaceTrack = true;
                for (Integer versionCode : track.getVersionCodes()) {
                    if (apk.getVersionCode() <= versionCode) {
                        replaceTrack = false;
                        break;
                    }
                }
                if (replaceTrack) {
                    Track removeTrack = new Track();
                    removeTrack.setTrack(app.getAppContext().getTrackType().getKey());
                    Edits.Tracks.Update removeTrackRequest = edits.tracks().update(app.getApplicationId(), editId, track.getTrack(), removeTrack);
                    removeTrackRequest.execute();
                    System.out.println(String.format("Track %s has been removed.", removeTrack.getTrack()));
                }
            }
        } else if (app.getAppContext().getTrackType().equals(TrackType.ROLLOUT)) {
            Track track = getTrack(app, edits, editId);
            if (track == null || track.getVersionCodes().isEmpty()) {
                if (app.getAppContext().getUserFraction() == null) {
                    app.getAppContext().setUserFraction(DEFAULT_USER_FRACTION);
                }
            } else {
                if (app.getAppContext().getUserFraction() == null) {
                    app.getAppContext().setUserFraction(track.getUserFraction());
                }
            }
        }
        // Assign apk to track.
        List<Integer> apkVersionCodes = new ArrayList<>();
        apkVersionCodes.add(apk.getVersionCode());
        Track track = new Track();
        track.setTrack(app.getAppContext().getTrackType().getKey());
        track.setVersionCodes(apkVersionCodes);
        track.setUserFraction(app.getAppContext().getUserFraction());
        Edits.Tracks.Update updateTrackRequest = edits.tracks().update(app.getApplicationId(), editId, track.getTrack(), track);
        Track updatedTrack = updateTrackRequest.execute();
        System.out.println(String.format("Track %s has been updated.", updatedTrack.getTrack()));
        for (LocaleListing each : app.getLocaleListings()) {
            String changelog = app.getChangelog(each, apk.getVersionCode());
            if (StringUtils.isNotBlank(changelog)) {
                // Update recent changes field in apk listing.
                ApkListing newApkListing = new ApkListing();
                newApkListing.setLanguage(each.getLanguageTag());
                newApkListing.setRecentChanges(changelog);
                Apklistings.Update updateRecentChangesRequest = edits.apklistings().update(app.getApplicationId(), editId, apk.getVersionCode(), each.getLanguageTag(), newApkListing);
                updateRecentChangesRequest.execute();
                System.out.println("Recent changes has been updated.");
            }
        }
        // Commit changes for edit.
        commitEdit(app, edits, editId);
    } catch (GoogleJsonResponseException ex) {
        if (!app.getAppContext().failOnApkUpgradeVersionConflict() && ex.getDetails().getCode() == 403 && ex.getDetails().getMessage().contains("apkUpgradeVersionConflict")) {
            System.out.println("WARNING | apkUpgradeVersionConflict: APK specifies a version code that has already been used.");
        } else {
            throw new UnexpectedException("Exception was thrown while uploading apk and updating recent changes", ex);
        }
    } catch (IOException ex) {
        throw new UnexpectedException("Exception was thrown while uploading apk and updating recent changes", ex);
    }
}

[Buggy Hunk]
if (!app.getAppContext().failOnApkUpgradeVersionConflict() && ex.getDetails().getCode() == 403 && ex.getDetails().getMessage().contains("apkUpgradeVersionConflict")) {

[Patch]
if (!app.getAppContext().failOnApkUpgradeVersionConflict() && ex.getDetails().getCode() == 403 && ex.getDetails().getMessage().equals("APK specifies a version code that has already been used.")) {