[Demonstration 1]

[Buggy Method]
protected String encrypt(byte[] content) {
    String result = null;
    try {
        Cipher aesCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        aesCipher.init(Cipher.ENCRYPT_MODE, skey_spec_, ivspec_);
        result = Base64.getEncoder().encodeToString(aesCipher.doFinal(content));
        return result;
    } catch (Exception e) {
        throw new RuntimeException("There is exception in encrypt!");
    }
}

[Buggy Hunk]
throw new RuntimeException("There is exception in encrypt!");

[Patch]
throw new RuntimeException(e);

[Demonstration 2]

[Buggy Method]
@Override
public void createMaterial(String token, MaterialDTO material) throws ServiceException, TokenException {
    validateToken(token);
    invalidArguments(FieldVerifier.isValidID("" + material.getMaterialID()) && FieldVerifier.isValidName(material.getMaterialName()) && FieldVerifier.isValidName(material.getProvider()));
    try {
        if (userDao.getUser(material.getMaterialID()) != null) {
            throw new ServiceException("MaterialID already exsists");
        }
        materialDao.createMaterial(material);
    } catch (DALException e) {
        throw new ServiceException(e);
    }
}

[Buggy Hunk]
if(userDao.getUser(material.getMaterialID()) != null){

[Patch]
if(materialDao.getMaterial(material.getMaterialID()) != null){

[Demonstration 3]

[Buggy Method]
public static String generateSign(String plainText, String cipher) {
    Mac mac;
    String algorithm = "hmacSha256";
    try {
        mac = Mac.getInstance(algorithm);
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(algorithm, e);
    }
    byte[] secretBytes = cipher.getBytes(StandardCharsets.UTF_8);
    try {
        mac.init(new SecretKeySpec(secretBytes, algorithm));
    } catch (InvalidKeyException e) {
        throw new RuntimeException("cipher : " + cipher, e);
    }
    byte[] signatureBytes = mac.doFinal(plainText.getBytes(StandardCharsets.UTF_8));
    return Base64.encodeBase64String(signatureBytes);
}

[Buggy Hunk]
return Base64.encodeBase64String(signatureBytes);

[Patch]
return Base64.encodeBase64URLSafeString(signatureBytes);