[Demonstration 1]

[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 2]

[Buggy Method]
public static void viewVolunteers() {
    // Display all the jobs of that park manager managed
    System.out.println("Select a job to view its volunteers:");
    // create list of Job -> calling Job class and getJob() in JobCOntroller
    List<Job> currentJobs = JobController.getJobs();
    if (currentJobs.isEmpty()) {
        System.out.println("You do not have any jobs -> so no volunteers!");
    } else {
        int i = 1;
        for (Job j : currentJobs) {
            System.out.print(i++ + ") ");
            System.out.print(j.getJobName() + " at ");
            System.out.print(j.getParkName() + " on ");
            System.out.println(j.getDateTime());
            System.out.println();
        }
        // Ask user to choose from the list
        //keyboard = new Scanner(System.in);
        System.out.print("Enter a number from the list: ");
        int choice = keyboard.nextInt();
        while (choice < 0 || choice > currentJobs.size()) {
            System.out.print("Please make a selection from the list: ");
            choice = keyboard.nextInt();
        }
        // Display volunteers of the selected jobs:
        System.out.println();
        System.out.println("Volunteers:");
        boolean volunteerFound = false;
        for (String volunteer : currentJobs.get(choice - 1)) {
            for (User u : UserController.getUserList()) {
                //get user from UserController
                if (u.equals("volunteer")) {
                    volunteerFound = true;
                    System.out.print(u.getFirstName() + " ");
                    System.out.print(u.getLastName() + ", ");
                }
            }
        }
        if (!volunteerFound) {
            System.out.println("No volunteers have signed up yet!");
        }
    }
    System.out.println();
}

[Buggy Hunk]
List <Job> currentJobs = JobController.getJobs();   // create list of Job -> calling Job class and getJob() in JobCOntroller

[Patch]
List <Job> currentJobs = jobController.getJobs();   // create list of Job -> calling Job class and getJob() in JobCOntroller

[Demonstration 3]

[Buggy Method]
@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {
    String achievementId = null;
    int numSteps;
    try {
        achievementId = arg1[0].getAsString();
        numSteps = arg1[0].getAsInt();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    Extension.context.achievements.setStepsAchivement(achievementId, numSteps);
    return null;
}

[Buggy Hunk]
numSteps = arg1[0].getAsInt();

[Patch]
numSteps = arg1[1].getAsInt();