[Demonstration 1]

[Buggy Method]
public static int getInt(String key) {
    return config.getInt(key);
}

[Buggy Hunk]
public static int getInt(String key){

[Patch]
public int getInt(String key) {

[Demonstration 2]

[Buggy Method]
public static PublicKey loadPublicKey(String stored) throws GeneralSecurityException {
    byte[] data = Base64.decode(stored, Base64.NO_WRAP);
    X509EncodedKeySpec spec = new X509EncodedKeySpec(data);
    KeyFactory fact = KeyFactory.getInstance("DH");
    return fact.generatePublic(spec);
}

[Buggy Hunk]
public static PublicKey loadPublicKey(String stored) throws GeneralSecurityException {

[Patch]
public static PublicKey loadPublicKey(String stored) throws GeneralSecurityException, IllegalArgumentException {

[Demonstration 3]

[Buggy Method]
public HashMap<String, String> Verify(String pemdata) {
    if (pemdata.indexOf(MIME_SIG_HEADER) != 0) {
        return null;
    }
    pemdata = pemdata.substring(pemdata.indexOf(MIME_SIG_HEADER) + MIME_SIG_HEADER.length());
    HashMap<String, String> result = new HashMap<String, String>();
    CMSSignedData sig = null;
    try {
        sig = new CMSSignedData(Base64.decode(pemdata, Base64.CRLF));
    } catch (CMSException e) {
        e.printStackTrace();
        return null;
    }
    CMSTypedData typed = sig.getSignedContent();
    ByteArrayOutputStream bofs = new ByteArrayOutputStream();
    try {
        typed.write(bofs);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return null;
    } catch (CMSException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return null;
    }
    String text = null;
    try {
        text = bofs.toString(java.nio.charset.StandardCharsets.UTF_8.name());
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return null;
    }
    // Append <msg> field
    result.put("msg", text);
    Store st = sig.getCertificates();
    SignerInformationStore signers = sig.getSignerInfos();
    Collection c = signers.getSigners();
    Iterator it = c.iterator();
    if (!it.hasNext()) {
        return null;
    }
    SignerInformation signer = (SignerInformation) it.next();
    Collection certCollection = st.getMatches(signer.getSID());
    Iterator certIt = certCollection.iterator();
    if (!certIt.hasNext()) {
        return null;
    }
    X509CertificateHolder certHolder = (X509CertificateHolder) certIt.next();
    try {
        if (signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build(certHolder))) {
            X509Certificate cert = new JcaX509CertificateConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME).getCertificate(certHolder);
            result.put("cert", EncodeCertificate(cert));
            return result;
        }
    } catch (OperatorCreationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (CertificateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (CMSException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

[Buggy Hunk]
text = bofs.toString(java.nio.charset.StandardCharsets.UTF_8.name());

[Patch]
text = bofs.toString("UTF-8");