[Demonstration 1]

[Buggy Method]
public FormValidation doTestConnection(@QueryParameter("artifactoryUrl") final String url, @QueryParameter("artifactory.timeout") final String timeout, @QueryParameter("artifactory.bypassProxy") final boolean bypassProxy, @QueryParameter("useCredentialsPlugin") final boolean useLegacyCredentials, @QueryParameter("credentialsId") final String deployerCredentialsId, @QueryParameter("username") final String deployerCredentialsUsername, @QueryParameter("password") final String deployerCredentialsPassword, @QueryParameter("doRetry") final boolean doRetry, @QueryParameter("maxRetry") final int maxRetry, @QueryParameter("retryRequestsAlreadySent") final boolean retryRequestsAlreadySent) throws ServletException {
    if (StringUtils.isBlank(url)) {
        return FormValidation.error("Please set a valid Artifactory URL");
    }
    if (maxRetry <= 0) {
        return FormValidation.error("Max Retries can not be less then 0");
    }
    Credentials credentials = PluginsUtils.credentialsLookup(deployerCredentialsId, null);
    String username = useLegacyCredentials ? credentials.getUsername() : deployerCredentialsUsername;
    String password = useLegacyCredentials ? credentials.getPassword() : deployerCredentialsPassword;
    ArtifactoryBuildInfoClient client;
    if (StringUtils.isNotBlank(username)) {
        client = new ArtifactoryBuildInfoClient(url, username, password, new NullLog());
    } else {
        client = new ArtifactoryBuildInfoClient(url, new NullLog());
    }
    if (!bypassProxy && Jenkins.getInstance().proxy != null) {
        client.setProxyConfiguration(RepositoriesUtils.createProxyConfiguration(Jenkins.getInstance().proxy));
    }
    if (StringUtils.isNotBlank(timeout))
        client.setConnectionTimeout(Integer.parseInt(timeout));
    RepositoriesUtils.setRetryParams(doRetry, maxRetry, retryRequestsAlreadySent, client);
    ArtifactoryVersion version;
    try {
        version = client.verifyCompatibleArtifactoryVersion();
    } catch (UnsupportedOperationException uoe) {
        return FormValidation.warning(uoe.getMessage());
    } catch (Exception e) {
        return FormValidation.error(e.getMessage());
    }
    return FormValidation.ok("Found Artifactory " + version.toString());
}

[Buggy Hunk]
if (maxRetry <= 0) {

[Patch]
if (maxRetry < 0) {

[Demonstration 2]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));

[Demonstration 3]

[Buggy Method]
private static XMLObject buildXMLObject(QName objectQualifiedName) throws SSOException {
    XMLObjectBuilder builder = new XMLObjectBuilderFactory().getBuilder(objectQualifiedName);
    if (builder == null) {
        throw new SSOException("Unable to retrieve builder for object QName " + objectQualifiedName);
    }
    return builder.buildObject(objectQualifiedName.getNamespaceURI(), objectQualifiedName.getLocalPart(), objectQualifiedName.getPrefix());
}

[Buggy Hunk]
XMLObjectBuilder builder = new XMLObjectBuilderFactory().getBuilder(objectQualifiedName);

[Patch]
XMLObjectBuilder builder = XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(objectQualifiedName);