[Demonstration 1]

[Buggy Method]
public WorkerEntry getBestApplicableWorker(String executorClass) {
    if (pool.isEmpty()) {
        log.info("No workers in pool");
        return null;
    }
    WorkerEntry stepEntry = null;
    for (WorkerEntry entry : pool.values()) {
        String inapplicableReason = entry.notApplicableReason();
        if (inapplicableReason != null) {
            //                if(!inapplicableReason.equals("Worker is busy")){
            //                    log.debug("Worker("+ entry +") not applicable: " + inapplicableReason);
            //                }
            continue;
        }
        if (entry.knownClasses.contains(executorClass)) {
            if (stepEntry == null || entry.lastIdleStart < stepEntry.lastIdleStart) {
                if (stepEntry != null) {
                    log.debug("PreSelectedWorker(" + stepEntry + ") losses to NewSelectedWorker(" + entry + ")");
                }
                stepEntry = entry;
            }
        }
    }
    if (stepEntry == null) {
        log.warn("No applicable or compatible worker in pool(size:" + pool.size() + ") for executor: " + executorClass);
    } else {
        stepEntry.idle = false;
    }
    return stepEntry;
}

[Buggy Hunk]
public WorkerEntry getBestApplicableWorker(String executorClass) {

[Patch]
public synchronized WorkerEntry getBestApplicableWorker(String executorClass) {

[Demonstration 2]

[Buggy Method]
@Override
public void saveDetailWithSettle(AchieveSettlementDetail detail) {
    this.achieveSettlementDetailDao.save(detail);
    List<AchieveSettlementDetail> details = this.achieveSettlementDetailDao.getAll();
    Double sum = 0.0;
    for (AchieveSettlementDetail dt : details) {
        sum += dt.getSettleAmount();
    }
    AchieveSettlement settlement = achieveSettlementDao.get(detail.getAchId());
    settlement.setCurrentSettleAmount(sum);
}

[Buggy Hunk]
List<AchieveSettlementDetail> details = this.achieveSettlementDetailDao.getAll();

[Patch]
List<AchieveSettlementDetail> details = this.achieveSettlementDetailDao.getAllByAchId(detail.getAchId());

[Demonstration 3]

[Buggy Method]
public int increaseStoneStored(float stone) {
    if (stone < 0) {
        if ((stone * (-1)) > this.stoneStored) {
            int difference = (int) stone + (int) this.stoneStored;
            this.stoneStored = 0;
            this.stoneRemaining -= (stone + difference);
            return difference;
        } else {
            this.stoneStored += stone;
            this.stoneRemaining -= stone;
        }
    } else {
        this.stoneStored += stone;
        this.stoneRemaining -= stone;
        if (this.stoneRemaining <= 0) {
            this.stoneRemaining = 0;
        }
    }
    return 0;
}

[Buggy Hunk]
this.stoneStored = 0;

[Patch]
this.stoneStored += (stone + difference);