[Demonstration 1]

[Buggy Method]
private void refreshInfo() {
    double total = 0d;
    double avg = 0d;
    double totalCat = 0d;
    double avgCat = 0d;
    double totalConv = 0d;
    double avgConv = 0d;
    double totalCatConv = 0d;
    double avgCatConv = 0d;
    double rate = 0d;
    Currency mainCur = StaticData.getMainCurrency();
    Account currentAcc = StaticData.getCurrentAccount();
    String mainCurrencySymbol = mainCur != null ? mainCur.getShortName() : "N/A";
    String currencySymbol = currentAcc != null ? currentAcc.getCurrency().getShortName() : "N/A";
    String currentCatName = "N/A";
    if (currentSelectedCategory != null && currentSelectedCategory.getName() != null) {
        // Getting possible aggregated name if needed
        StatsCategoryValues scv = statsData.get(currentSelectedCategory.getId());
        currentCatName = scv != null ? scv.getName() : currentSelectedCategory.getName();
        if (currentCatName.length() > 11) {
            currentCatName = currentSelectedCategory.getName().substring(0, 11);
            if (!currentCatName.equals(currentSelectedCategory.getName()))
                currentCatName += ".";
        }
    }
    if (statsData.values() != null || statsData.values().size() > 0) {
        /**
         * Gran total *
         */
        Iterator<StatsCategoryValues> it = statsData.values().iterator();
        while (it.hasNext()) {
            StatsCategoryValues scv = it.next();
            total += scv.summarize();
            rate += scv.getRate();
        }
        // Get the average of all rates
        rate /= statsData.size();
        /**
         * Avg by day *
         */
        int nbDays = DateUtil.getNumberOfDaysBetweenDates(dateBegin, dateEnd);
        avg = total / nbDays;
        /**
         * Total and avg by day by category *
         */
        if (currentSelectedCategory != null && currentSelectedCategory.getId() != null) {
            StatsCategoryValues scv = statsData.get(currentSelectedCategory.getId());
            if (scv != null) {
                totalCat = scv.summarize();
                avgCat = scv.average(dateBegin, dateEnd);
            }
        }
        /**
         * Gran total conversion to main currency *
         */
        totalConv = total / rate;
        totalCatConv = totalCat / rate;
        avgConv = avg / rate;
        avgCatConv = avgCat / rate;
    }
    /**
     * Setting all data to TextViews *
     */
    tvAvg1Currency.setText(currencySymbol);
    tvAvg1Amount.setText(NumberUtil.formatDecimal(avg));
    tvAvg2Currency.setText(mainCurrencySymbol);
    tvAvg2Amount.setText(NumberUtil.formatDecimal(avgConv));
    tvAvg1Cat.setText(currentCatName);
    tvAvg1CatCurrency.setText(currencySymbol);
    tvAvg1CatAmount.setText(NumberUtil.formatDecimal(avgCat));
    tvAvg2CatCurrency.setText(mainCurrencySymbol);
    tvAvg2CatAmount.setText(NumberUtil.formatDecimal(avgCatConv));
    tvTotal1Currency.setText(currencySymbol);
    tvTotal1Amount.setText(NumberUtil.formatDecimal(total));
    tvTotal2Currency.setText(mainCurrencySymbol);
    tvTotal2Amount.setText(NumberUtil.formatDecimal(totalConv));
    tvTotal1Cat.setText(currentCatName);
    tvTotal1CatCurrency.setText(currencySymbol);
    tvTotal1CatAmount.setText(NumberUtil.formatDecimal(totalCat));
    tvTotal2CatCurrency.setText(mainCurrencySymbol);
    tvTotal2CatAmount.setText(NumberUtil.formatDecimal(totalCatConv));
}

[Buggy Hunk]
String currencySymbol = currentAcc != null ? currentAcc.getCurrency().getShortName() : "N/A";

[Patch]
String currencySymbol = currentAcc != null && currentAcc.getCurrency() != null ? currentAcc.getCurrency().getShortName() : "N/A";

[Demonstration 2]

[Buggy Method]
public static StreamStatus checkStream(CoverityPublisher publisher, CIMStream cs) {
    if (cs == null || cs.getInstance() == null) {
        return new StreamStatus(false, "Could not connect to a Coverity instance. \n " + "Verify that a Coverity instance has been configured for this job", cs, null);
    }
    CIMInstance ci = publisher.getDescriptor().getInstance(cs.getInstance());
    if (ci == null) {
        return new StreamStatus(false, "Could not connect to a Coverity instance. \n " + "Verify that a Coverity instance has been configured for this job", cs, null);
    }
    if (cs.getStream() == null) {
        return new StreamStatus(false, "Could not find any Stream that matches the given configuration for this job.", cs, null);
    }
    //check if instance is valid
    {
        try {
            FormValidation fv = ci.doCheck();
            if (fv.kind != FormValidation.Kind.OK) {
                return new StreamStatus(false, "Could not connect to instance: " + fv, cs, null);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new StreamStatus(false, "Could not connect to instance: " + e, cs, null);
        }
    }
    //check instance version
    CoverityVersion version = null;
    {
        try {
            version = CoverityVersion.parse(ci.getConfigurationService().getVersion().getExternalVersion());
        } catch (CovRemoteServiceException_Exception e) {
            e.printStackTrace();
            return new StreamStatus(false, "Could not retrieve version info: " + e, cs, null);
        } catch (IOException e) {
            e.printStackTrace();
            return new StreamStatus(false, "Could not retrieve version info: " + e, cs, null);
        }
    }
    //check stream
    {
        try {
            StreamFilterSpecDataObj sf = new StreamFilterSpecDataObj();
            sf.setNamePattern(cs.getStream());
            List<StreamDataObj> ls = ci.getConfigurationService().getStreams(sf);
            if (ls.size() == 0) {
                return new StreamStatus(false, "Stream does not exist", cs, version);
            }
        } catch (CovRemoteServiceException_Exception e) {
            e.printStackTrace();
            return new StreamStatus(false, "Could not find stream: " + e, cs, version);
        } catch (IOException e) {
            e.printStackTrace();
            return new StreamStatus(false, "Could not find stream: " + e, cs, version);
        }
    }
    return new StreamStatus(true, "OK (version: " + version + ")", cs, version);
}

[Buggy Hunk]
if(fv.kind != FormValidation.Kind.OK) {

[Patch]
if(fv.kind == Kind.ERROR) {

[Demonstration 3]

[Buggy Method]
private void toScreenFirstStudyDate() {
    long firstStudyDate = answerDataByCard.getFirstStudyDate();
    if (firstStudyDate != Long.MIN_VALUE) {
        jLabel9.setText(new Date(firstStudyDate).toString());
    } else {
        jLabel9.setText("-");
    }
}

[Buggy Hunk]
if (firstStudyDate != Long.MIN_VALUE) {

[Patch]
if (firstStudyDate > 0) {