[Demonstration 1]

[Buggy Method]
public static IJavaProject createOrOpenProject(ProjectNode projectNode, String projectName, IProgressMonitor monitor) throws CoreException, IllegalArgumentException {
    final AtomicReference<IJavaProject> ar = new AtomicReference<IJavaProject>();
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IProject project = workspace.getRoot().getProject(projectName);
    final RepositoryNode repoNode = (RepositoryNode) projectNode.getContainer();
    Repository repository = ((KieRepositoryHandler) repoNode.getHandler()).getRepository();
    final IPath location = new Path(repository.getWorkTree().toString()).append(projectName);
    if (project.exists()) {
        if (!project.isOpen()) {
            IPath oldLocation = project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME).getLocation();
            if (oldLocation != null && oldLocation.equals(location)) {
                project.open(monitor);
                project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                return null;
            }
        }
        throw new IllegalArgumentException("The Project " + projectName + " already exists");
    }
    WorkspaceModifyOperation op = new WorkspaceModifyOperation() {

        protected void execute(IProgressMonitor monitor) throws CoreException {
            try {
                IProjectDescription pd = workspace.newProjectDescription(projectName);
                pd.setLocation(location);
                // add the natures and builders
                FileUtils.addJavaNature(pd);
                FileUtils.addMavenNature(pd);
                project.create(pd, new SubProgressMonitor(monitor, 30));
                project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 50));
                // create a default runtime if one does not exist
                IRuntime runtime = runtimeManager.getEffectiveRuntime(null, true);
                runtimeManager.setRuntime(runtime, project, monitor);
                IJavaProject javaProject = JavaCore.create(project);
                FileUtils.createOutputLocation(javaProject, "bin", monitor);
                FileUtils.addJavaBuilder(javaProject, monitor);
                FileUtils.addMavenBuilder(javaProject, monitor);
                runtimeManager.addBuilder(javaProject, monitor);
                FileUtils.addFolderToClasspath(javaProject, "src/main/java", true, monitor);
                FileUtils.addFolderToClasspath(javaProject, "src/main/resources", true, monitor);
                FileUtils.addFolderToClasspath(javaProject, "src/main/rules", true, monitor);
                ar.set(javaProject);
                FileUtils.createFolder(javaProject, "src/main/resources/META-INF", monitor);
                FileUtils.createFolder(javaProject, "src/main/resources/META-INF/maven", monitor);
                JsonObject projectProperties = projectNode.getHandler().getProperties();
                JsonValue jv = projectProperties.get("groupId");
                String groupId = null;
                if (jv == null || jv.asString().isEmpty()) {
                    if (projectNode.getParent() instanceof RepositoryNode) {
                        JsonObject orgProperties = projectNode.getParent().getParent().getHandler().getProperties();
                        jv = orgProperties.get("defaultGroupId");
                    }
                }
                if (jv != null)
                    groupId = jv.asString();
                String artifactId = null;
                jv = projectProperties.get("artifactId");
                if (jv != null)
                    artifactId = jv.asString();
                String version = null;
                jv = projectProperties.get("version");
                if (jv != null)
                    version = jv.asString();
                FileUtils.createMavenArtifacts(javaProject, groupId, artifactId, version, monitor);
                FileUtils.createKJarArtifacts(javaProject, monitor);
                project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            } catch (Exception e) {
                ErrorDialog.openError(Display.getDefault().getActiveShell(), "Problem creating new project", e.getMessage(), null);
            }
        }
    };
    try {
        op.run(monitor);
    } catch (Throwable t) {
        t.printStackTrace();
    }
    return ar.get();
}

[Buggy Hunk]
public static IJavaProject createOrOpenProject(ProjectNode projectNode, String projectName, IProgressMonitor monitor)

[Patch]
public static IJavaProject createOrOpenProject(final ProjectNode projectNode, final String projectName, final IProgressMonitor monitor)

[Demonstration 2]

[Buggy Method]
public void loadViolatedResources(final Rule rule, final String ruleKey, final String projectKey) throws ReportException, UnsupportedEncodingException {
    if (ruleKey == null) {
        throw new ReportException("Rule not initialized. Forget call to initFromNode() previously?");
    } else {
        // ruleKey = URLEncoder.encode(ruleKey, "UTF8");
        LOG.debug("Accessing Sonar: getting violated resurces by one given rule (" + ruleKey + ")");
        SonarClient client = SonarClient.create(credentials.getUrl());
        IssueClient issueClient = client.issueClient();
        IssueQuery issueQuery = IssueQuery.create();
        issueQuery.componentRoots(projectKey);
        issueQuery.pageSize(20);
        issueQuery.rules(ruleKey);
        // "&scopes=FIL&depth=-1&limit=20
        Issues issues = issueClient.find(issueQuery);
        List<Issue> violatedResources = issues.list();
        List<Violation> topViolatedResources = new LinkedList<Violation>();
        rule.setTopViolatedResources(topViolatedResources);
        Iterator<Issue> it = violatedResources.iterator();
        while (it.hasNext()) {
            Issue resource = it.next();
            if (rule.getMessage() == null) {
                rule.setMessage(resource.message());
            }
            // resource key as: net.java.openjdk:jdk7:src/com/sun/rowset/internal/CachedRowSetReader.java
            String resourceKey = resource.componentKey();
            String line = "N/A";
            Integer resourceLine = resource.line();
            if (resourceLine != null) {
                line = String.valueOf(resourceLine);
            }
            topViolatedResources.add(new Violation(line, resourceKey, ""));
        }
    }
}

[Buggy Hunk]
issueQuery.componentRoots(projectKey);

[Patch]
issueQuery.components(projectKey);

[Demonstration 3]

[Buggy Method]
private static void loadBannedItems() {
    bannedItems.clear();
    File file = new File(saveDir, "banneditems.cfg");
    if (!file.exists()) {
        bannedItems.put(new ItemStack(Blocks.command_block), new HashSet<String>(Arrays.asList("NONE")));
        saveBannedItems();
        return;
    }
    try {
        FileReader r = new FileReader(file);
        int line = 0;
        for (String s : IOUtils.readLines(r)) {
            if (s.charAt(0) == '#' || s.trim().length() == 0)
                continue;
            int delim = s.lastIndexOf('=');
            if (delim < 0) {
                logger.error("line " + line + ": Missing =");
                continue;
            }
            try {
                NBTTagCompound key = JsonToNBT.func_180713_a(s.substring(0, delim));
                Set<String> values = new HashSet<String>();
                for (String s2 : s.substring(delim + 1).split(",")) values.add(s2.trim());
                bannedItems.put(InventoryUtils.loadPersistant(key), values);
            } catch (Exception e) {
                logger.error("line " + line + ": " + e.getMessage());
            }
        }
        r.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

[Buggy Hunk]
NBTTagCompound key = JsonToNBT.func_180713_a(s.substring(0, delim));

[Patch]
NBTTagCompound key = JsonToNBT.getTagFromJson(s.substring(0, delim));