[Demonstration 1]

[Buggy Method]
@SuppressLint("UseSparseArrays")
@Override
public void onManagerConnected(int status) {
    switch(status) {
        case LoaderCallbackInterface.SUCCESS:
            {
                Log.i(TAG, "OpenCV loaded successfully");
                // Load native library after(!) OpenCV initialization
                System.loadLibrary("detection_based_tracker");
                System.loadLibrary("adaptive_histogram");
                System.loadLibrary("face_recog_native");
                System.loadLibrary("hmm_native");
                // Model setup
                faceRecognizer = new FaceRec2();
                faceRecognizer.train();
                if (!faceRecognizer.trainingSetEmpty()) {
                    hmm = new Hmm(faceRecognizer.numSubjects());
                    hashMap = new HashMap<Integer, Integer>();
                    idsSet = faceRecognizer.getSeenIds();
                    // Map the real ids to a range starting from 0
                    for (int i = 0; i < faceRecognizer.numSubjects(); ++i) {
                        hashMap.put(idsSet.get(i), Integer.valueOf(i));
                    }
                }
                try {
                    // load cascade file from application resources
                    InputStream is = getResources().openRawResource(R.raw.lbpcascade_frontalface);
                    File cascadeDir = getDir("cascade", Context.MODE_PRIVATE);
                    mCascadeFile = new File(cascadeDir, "lbpcascade_frontalface.xml");
                    FileOutputStream os = new FileOutputStream(mCascadeFile);
                    byte[] buffer = new byte[4096];
                    int bytesRead;
                    while ((bytesRead = is.read(buffer)) != -1) {
                        os.write(buffer, 0, bytesRead);
                    }
                    is.close();
                    os.close();
                    mJavaDetector = new CascadeClassifier(mCascadeFile.getAbsolutePath());
                    if (mJavaDetector.empty()) {
                        Log.e(TAG, "Failed to load cascade classifier");
                        mJavaDetector = null;
                    } else
                        Log.i(TAG, "Loaded cascade classifier from " + mCascadeFile.getAbsolutePath());
                    mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0);
                    cascadeDir.delete();
                } catch (IOException e) {
                    e.printStackTrace();
                    Log.e(TAG, "Failed to load cascade. Exception thrown: " + e);
                }
                mOpenCvCameraView.enableView();
            }
            break;
        default:
            {
                super.onManagerConnected(status);
            }
            break;
    }
}

[Buggy Hunk]
if (!faceRecognizer.trainingSetEmpty()) {

[Patch]
if (!faceRecognizer.trainingSetEmpty() && !faceRecognizer.isSingularTrainingSet()) {

[Demonstration 2]

[Buggy Method]
@Override
public void execute(Response resp) throws InterruptedException, SuspendExecution {
    // TODO Auto-generated method stub
    System.out.println("");
    this.displayPlan();
    System.out.println("");
    if (this.reqRate != 0) {
        this.running = true;
        this.reqsDetails.clear();
        for (int i = 0; i < httpreqlist.size(); i++) {
            Output outputrow = new Output();
            Date now = new Date();
            String strDate = sdf.format(now);
            outputrow.setRequest("TestPlan-" + this.getId() + "-Request-" + (i + 1));
            outputrow.setTime(strDate);
            outputrow.setInputload("0 reqs/sec");
            outputrow.setErrorrate("0%");
            outputrow.setAvgThroughput("0 reqs/sec");
            outputrow.setCurThroughput("0 reqs/sec");
            outputrow.setResponsetime("0 msec");
            MainController.outputlist.set(this.getOutputrowstart() + i, outputrow);
            List<Long> temp = new ArrayList<Long>();
            // Send Request Rate
            temp.add((long) 0);
            // Success Request count
            temp.add((long) 0);
            // Error Request count
            temp.add((long) 0);
            // Current Throughput
            temp.add((long) 0);
            // Response Time
            temp.add((long) 0);
            this.reqsDetails.put(httpreqlist.get(i), temp);
            // totalresptimes.put(httpreqlist.get(i), (long) 0);
        }
        /*
			 * System.out.println("Duration : "+ duration);
			 * System.out.println("Reqrate : "+ reqRate);
			 */
        Fiber.sleep(this.getStartDelay() * 1000);
        if (this.random == 1) {
            //System.out.println("Epoch Number : " + this.getId());
            logger.info("Epoch Number : " + this.getId());
        }
        int fiberArraysize = this.duration * this.reqRate;
        Fiber[] fibers = new Fiber[fiberArraysize];
        //System.out.println("Array Size = " + fiberArraysize);
        final int num = this.duration * this.reqRate;
        // int runningcount=num;
        this.setRunningcount(num);
        final RateLimiter rl = RateLimiter.create(this.reqRate);
        Date now1 = new Date();
        logger.info("starttime " + sdf.format(now1));
        this.outputFiber();
        final Semaphore sem = new Semaphore(1500000);
        for (int i = 0; i < num && MainController.test; i++) {
            rl.acquire();
            if (sem.availablePermits() == 0)
                logger.info("Maximum connections count reached, waiting...");
            sem.acquireUninterruptibly();
            new Fiber<Void>(() -> {
                try {
                    int k = 0;
                    Response currresp = new Response();
                    for (k = 0; k < this.testPlan.size(); k++) {
                        if (this.reqsDetails.get(k) != null) {
                            this.reqsDetails.get(k).set(0, (this.reqsDetails.get(k).get(0)) + 1);
                            long startTime = System.currentTimeMillis();
                            ((Feature) this.testPlan.get(k)).execute(currresp);
                            long elapsedTime = System.currentTimeMillis() - startTime;
                            if (currresp.getResponse().getStatusLine().toString().contains("OK")) {
                                this.reqsDetails.get(k).set(1, this.reqsDetails.get(k).get(1) + 1);
                                this.reqsDetails.get(k).set(2, this.reqsDetails.get(k).get(2));
                                this.reqsDetails.get(k).set(3, this.reqsDetails.get(k).get(3) + 1);
                                this.reqsDetails.get(k).set(4, this.reqsDetails.get(k).get(4) + elapsedTime);
                            } else {
                                this.reqsDetails.get(k).set(1, this.reqsDetails.get(k).get(1));
                                this.reqsDetails.get(k).set(2, this.reqsDetails.get(k).get(2) + 1);
                                this.reqsDetails.get(k).set(3, this.reqsDetails.get(k).get(3));
                                this.reqsDetails.get(k).set(4, this.reqsDetails.get(k).get(4));
                            }
                        } else {
                            ((Feature) this.testPlan.get(k)).execute(currresp);
                        }
                    }
                } catch (final Throwable t) {
                } finally {
                    // logger.info("inside finally");
                    sem.release();
                    this.setRunningcount(this.getRunningcount() - 1);
                }
            }).start();
        }
        Fiber.sleep(this.duration * 1000);
        while (true) {
            // logger.info(this.getRunningcount());
            if (this.runningcount <= 0) {
                this.running = false;
                break;
            }
        }
        Date now2 = new Date();
        logger.info("endtime " + sdf.format(now2));
        /*
			 * if (!MainController.test) { MainController.test = true; }
			 */
        try {
            fileWriter.flush();
            fileWriter.close();
        } catch (IOException e) {
            logger.info("Error while flushing/closing fileWriter !!!");
            e.printStackTrace();
        }
    }
    logger.info("TestPlan Finished");
}

[Buggy Hunk]
System.out.println(""); this.displayPlan(); System.out.println("");

[Patch]
this.displayPlan();

[Demonstration 3]

[Buggy Method]
public void deleteAllHistory() {
    String libraryId = PreferenceUtil.getString(PreferenceUtil.LIBRARY_ID);
    db.execSQL("DELETE FROM " + DataBase.TABLE_SEARCH_HISTORY + " WHERE " + DataBase.KEY_LIBRARY_USER_ID + " = ? " + new String[] { libraryId });
}

[Buggy Hunk]
" WHERE " + DataBase.KEY_LIBRARY_USER_ID + " = ? " +

[Patch]
" WHERE " + DataBase.KEY_LIBRARY_USER_ID + " = ? ",