[Demonstration 1]

[Buggy Method]
@RequestMapping(value = "{entityType}/{entityId}/document/{documentId}", method = RequestMethod.DELETE)
@Transactional
public void delete(@PathVariable String entityType, @PathVariable long entityId, @PathVariable long documentId) throws MentorMeException {
    List<Document> docs;
    if (EntityTypes.MENTEE_MENTOR_PROGRAM.equalsIgnoreCase(entityType)) {
        docs = menteeMentorProgramService.get(entityId).getDocuments();
    } else if (EntityTypes.MENTEE_MENTOR_GOAL.equalsIgnoreCase(entityType)) {
        docs = menteeMentorGoalService.get(entityId).getDocuments();
    } else {
        throw new MentorMeException("The provided entityType is unknown.");
    }
    boolean removed = false;
    Iterator<Document> it = docs.iterator();
    while (it.hasNext()) {
        Document doc = it.next();
        if (doc.getId() == documentId) {
            it.remove();
            removed = true;
            break;
        }
    }
    if (!removed) {
        throw new EntityNotFoundException("The document is not in the entity");
    }
}

[Buggy Hunk]
docs = menteeMentorGoalService.get(entityId).getDocuments();

[Patch]
docs = menteeMentorGoalService.get(entityId).getGoal().getDocuments();

[Demonstration 2]

[Buggy Method]
public double fixDoubleDigi(double price) {
    if (price < 1.0) {
        double prices = price;
        DecimalFormat df = new DecimalFormat("#.#####");
        price = Double.valueOf(df.format(prices));
        return price = Math.round(prices * 10000.0) / 10000.0;
    } else if (price < 10.0) {
        double prices = price;
        DecimalFormat df = new DecimalFormat("#.####");
        price = Double.valueOf(df.format(prices));
        price = Math.round(prices * 1000.0) / 1000.0;
        return price;
    } else if (price < 100.0) {
        double prices = price;
        DecimalFormat df = new DecimalFormat("##.###");
        price = Double.valueOf(df.format(prices));
        price = Math.round(prices * 100.0) / 100.0;
        return price;
    } else {
        double prices = price;
        DecimalFormat df = new DecimalFormat("###.###");
        price = Double.valueOf(df.format(prices));
        price = Math.round(prices * 100.0) / 100.0;
        return price;
    }
}

[Buggy Hunk]
public double fixDoubleDigi(double price){

[Patch]
private double fixDoubleDigi(double price){

[Demonstration 3]

[Buggy Method]
@Override
public boolean add(E e) {
    if (e == null)
        throw new NullPointerException("Cannot add a null element to a Magic Set");
    return map.put(e.getId(), e) == null;
}

[Buggy Hunk]
throw new NullPointerException("Cannot add a null element to a Magic Set");

[Patch]
throw new IllegalArgumentException("Cannot add a null element to a Magic Set");