[Demonstration 1]

[Buggy Method]
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = { "REC_CATCH_EXCEPTION" }, justification = "Using catch all to detect invalid dates.")
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.NPathComplexity" })
@Override
public void validate(Object target, Errors errors) {
    if (target instanceof PenaltyParametersDto) {
        return;
    }
    PenaltyFormBean formBean = (PenaltyFormBean) target;
    checkCategory(errors, formBean.getCategoryTypeId());
    checkStatus(errors, formBean.getStatusId());
    if (StringUtils.hasText(formBean.getPeriodTypeId()) && !formBean.getPeriodTypeId().equalsIgnoreCase("3")) {
        checkNumber(errors, formBean.getDuration(), "Grace Period Duration", digits);
    } else {
        incorrectIntegerValue(errors, formBean.getDuration(), "Grace Period Duration", digits);
    }
    emptyField(errors, formBean.getName(), "Penalty Name");
    emptyField(errors, formBean.getFrequencyId(), "Penalty Application Frequency");
    emptyField(errors, formBean.getGlCodeId(), "GL Code");
    checkNumber(errors, formBean.getMin(), "Cumulative Penalty Limit (Minimum)", digits, decimal);
    checkNumber(errors, formBean.getMax(), "Cumulative Penalty Limit (Maximum)", digits, decimal);
    checkMinGreaterMax(errors, formBean.getMin(), formBean.getMax());
    if (StringUtils.hasText(formBean.getCategoryTypeId()) && formBean.getCategoryTypeId().equalsIgnoreCase("1")) {
        if (StringUtils.hasText(formBean.getRate()) && StringUtils.hasText(formBean.getAmount())) {
            errors.reject("error.penalty.amountAndRateOrFormula");
        } else if (StringUtils.hasText(formBean.getRate()) && StringUtils.hasText(formBean.getFormulaId())) {
            checkNumber(errors, formBean.getRate(), "Rate", digits, decimal);
        } else if (StringUtils.hasText(formBean.getRate()) && !StringUtils.hasText(formBean.getFormulaId())) {
            errors.reject("error.penalty.rate");
        } else if (StringUtils.hasText(formBean.getAmount())) {
            checkNumber(errors, formBean.getAmount(), "Amount", digits, decimal);
        } else {
            errors.reject("error.penalty.amountAndRateOrFormula");
        }
    } else {
        checkNumber(errors, formBean.getAmount(), "Amount", digits, decimal);
    }
}

[Buggy Hunk]
incorrectIntegerValue(errors, formBean.getDuration(), "Grace Period Duration", digits);

[Patch]
formBean.setDuration("");

[Demonstration 2]

[Buggy Method]
public void mouseClicked(MouseEvent e) {
    // pause = !pause;
    int x = e.getX() / cellSize - 1;
    int y = e.getY() / cellSize;
    if (x < 20 && y < 20) {
        if (mouseState == 0)
            myWorld.getCreatures().add(new SquareTurtle(new Location(x, y), 3));
        if (mouseState == 1)
            myWorld.getCreatures().add(new Shark(new Location(x, y), 0, true, true, true));
        if (mouseState == 2)
            myWorld.getCreatures().add(new SharkBoat(new Location(x, y), myWorld));
        if (mouseState == 3)
            myWorld.getCreatures().add(new JellyFish(new Location(x, y)));
    }
}

[Buggy Hunk]
new JellyFish(new Location(x, y)));

[Patch]
new JellyFish(new Location(x+1, y+1)));

[Demonstration 3]

[Buggy Method]
public void run() {
    for (; r <= radius; r++) {
        for (; x <= r; x++) {
            for (; z <= r; z++) {
                for (int y = 0; y <= r; y++) {
                    Location curPPloc = new Location(location.getWorld(), location.getX() + x, location.getY() + y, location.getZ() + z);
                    Location curPNloc = new Location(location.getWorld(), location.getX() + x, location.getY() + y, location.getZ() - z);
                    Location curNPloc = new Location(location.getWorld(), location.getX() - x, location.getY() + y, location.getZ() + z);
                    Location curNNloc = new Location(location.getWorld(), location.getX() - x, location.getY() + y, location.getZ() - z);
                    if (location.distance(curPPloc) < r) {
                        boolean brokeblock = false;
                        brokeblock = breakBlock(curPPloc.getBlock()) ? true : brokeblock;
                        brokeblock = breakBlock(curPNloc.getBlock()) ? true : brokeblock;
                        brokeblock = breakBlock(curNPloc.getBlock()) ? true : brokeblock;
                        brokeblock = breakBlock(curNNloc.getBlock()) ? true : brokeblock;
                        if (brokeblock) {
                            return;
                        }
                    }
                }
                // for y
                y = 0;
            }
            // for z
            z = 0;
        }
        // for x
        x = 0;
    }
    // for r
    plugin.getServer().getScheduler().cancelTask(taskid);
    sender.sendMessage("Completed cavern carver job " + taskid);
}

[Buggy Hunk]
for (int y = 0; y <= r; y++) {

[Patch]
for (; y <= r; y++) {