[Demonstration 1]

[Buggy Method]
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    _name = (String) params.get(NAME);
    if (_name == null) {
        throw new ConfigurationException("Unable to find name");
    }
    _guid = (String) params.get(GUID);
    if (_guid == null) {
        throw new ConfigurationException("Unable to find the guid");
    }
    _zoneId = (String) params.get(ZONE_ID);
    if (_zoneId == null) {
        throw new ConfigurationException("Unable to find zone");
    }
    _hostName = (String) params.get(HOST_NAME);
    if (Strings.isNullOrEmpty(_hostName)) {
        throw new ConfigurationException("Unable to find hostname");
    }
    String cmsUser = (String) params.get(CMS_USER);
    if (Strings.isNullOrEmpty(cmsUser)) {
        throw new ConfigurationException("Unable to find CMS username");
    }
    String cmsUserPassBase64 = (String) params.get(CMS_USER_PASSWORD);
    if (Strings.isNullOrEmpty(cmsUserPassBase64)) {
        throw new ConfigurationException("Unable to find CMS password");
    }
    String port = (String) params.get(PORT);
    if (Strings.isNullOrEmpty(port)) {
        throw new ConfigurationException("Unable to find port");
    }
    String apiVersion = (String) params.get(API_VERSION);
    if (Strings.isNullOrEmpty(apiVersion)) {
        throw new ConfigurationException("Unable to find API version");
    } else if (!Pattern.matches("v\\d+_\\d+", apiVersion)) {
        throw new ConfigurationException("Incorrect API version");
    }
    String apiRelativePath = (String) params.get(API_RELATIVE_PATH);
    if (Strings.isNullOrEmpty(apiRelativePath) || !apiRelativePath.contains(apiVersion)) {
        throw new ConfigurationException("Unable to find API version in relative path");
    }
    String retryCount = (String) params.get(RETRY_COUNT);
    if (!Strings.isNullOrEmpty(retryCount)) {
        try {
            _numRetries = Integer.parseInt(retryCount);
        } catch (NumberFormatException ex) {
            throw new ConfigurationException("Number of retries has to be between 1 and 10");
        }
        if ((_numRetries < 1) || (_numRetries > 10)) {
            throw new ConfigurationException("Number of retries has to be between 1 and 10");
        }
    } else {
        throw new ConfigurationException("Unable to find number of retries");
    }
    String retryInterval = (String) params.get(RETRY_INTERVAL);
    if (!Strings.isNullOrEmpty(retryInterval)) {
        try {
            _retryInterval = Integer.parseInt(retryInterval);
        } catch (NumberFormatException ex) {
            throw new ConfigurationException("Retry interval has to be between 0 and 10000 ms");
        }
        if ((_retryInterval < 0) || (_retryInterval > 10000)) {
            throw new ConfigurationException("Retry interval has to be between 0 and 10000 ms");
        }
    } else {
        throw new ConfigurationException("Unable to find retry interval");
    }
    _relativePath = new StringBuffer().append("https://").append(_hostName).append(":").append(port).append(apiRelativePath).toString();
    String cmsUserPass = org.apache.commons.codec.binary.StringUtils.newStringUtf8(Base64.decodeBase64(cmsUserPassBase64));
    _cmsUserInfo = new String[] { CMS_USER_ENTEPRISE_NAME, cmsUser, cmsUserPass };
    _nuageVspCmsId = (String) params.get(NUAGE_VSP_CMS_ID);
    loadNuageClient();
    try {
        login();
    } catch (ExecutionException | ConfigurationException e) {
        s_logger.error("Failed to login to Nuage VSD on " + name + " as user " + cmsUser, e);
        throw new CloudRuntimeException("Failed to login to Nuage VSD on " + name + " as user " + cmsUser, e);
    }
    return true;
}

[Buggy Hunk]
String cmsUserPass = org.apache.commons.codec.binary.StringUtils.newStringUtf8(Base64.decodeBase64(cmsUserPassBase64));

[Patch]
String cmsUserPass = NuageVspUtil.decodePassword(cmsUserPassBase64);

[Demonstration 2]

[Buggy Method]
public static String fromSeconds(long seconds) {
    long hour = seconds / 3600;
    long minute = ((seconds / 60) % 60);
    long second = seconds % 60;
    ChatColor gold = ChatColor.GOLD;
    ChatColor red = ChatColor.RED;
    StringBuilder sb = new StringBuilder();
    sb.append(hour != 0 ? "" + red + hour + gold + "hr " : "");
    sb.append(minute != 0 ? "" + red + minute + gold + "min " : "");
    sb.append(second != 0 ? "" + red + second + gold + "sec " : "");
    String sbs = sb.toString();
    return sbs.substring(0, sbs.length() - 1);
}

[Buggy Hunk]
sb.append(second != 0 ? "" + red + second + gold + "sec " : "");

[Patch]
sb.append("" + red + second + gold + "sec ");

[Demonstration 3]

[Buggy Method]
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
    for (BaseRuntimeChildDefinition next : myExtensions) {
        next.sealAndInitialize(theClassToElementDefinitions);
    }
    for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
        String extUrl = next.getExtensionUrl();
        if (myUrlToExtension.containsKey(extUrl)) {
            throw new ConfigurationException("Duplicate extension URL: " + extUrl);
        } else {
            myUrlToExtension.put(extUrl, next);
        }
        if (next.isModifier()) {
            myExtensionsModifier.add(next);
        } else {
            myExtensionsNonModifier.add(next);
        }
    }
    myExtensions = Collections.unmodifiableList(myExtensions);
}

[Buggy Hunk]
throw new ConfigurationException("Duplicate extension URL: " + extUrl);

[Patch]
throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]");