[Demonstration 1]

[Buggy Method]
public static String getPomVersion(File file) {
    String version = "";
    try {
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder;
        dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(file);
        doc.getDocumentElement().normalize();
        XPath xPath = XPathFactory.newInstance().newXPath();
        String expression = "/project/version";
        NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node nNode = nodeList.item(i);
            version = nNode.getTextContent();
        }
    } catch (ParserConfigurationException e) {
        log.error("Error occered when parsing the pom.xml file to retrive the pom version");
    } catch (SAXException e) {
        log.error("Error occered when parsing the pom.xml");
    } catch (IOException e) {
        log.error("Specified pom file is not found in the location");
    } catch (XPathExpressionException e) {
        log.error("No valid XPATH found");
    }
    return version;
}

[Buggy Hunk]
= DocumentBuilderFactory.newInstance();

[Patch]
= XmlDomParser.getSecuredDocumentBuilderFactory();

[Demonstration 2]

[Buggy Method]
public void onArticleSelected(String position) {
    // The user selected the headline of an article from the HeadlinesFragment
    // Capture the article fragment from the activity layout
    DetailPlugFragment articleFrag = (DetailPlugFragment) getSupportFragmentManager().findFragmentById(R.id.plug_details);
    if (articleFrag != null) {
        // If article frag is available, we're in two-pane layout...
        // Call a method in the ArticleFragment to update its content
        articleFrag.updateArticleView(position);
    } else {
        // If the frag is not available, we're in the one-pane layout and must swap frags...
        // Create fragment and give it an argument for the selected article
        DetailPlugFragment newFragment = new DetailPlugFragment();
        Bundle args = new Bundle();
        args.putString(DetailPlugFragment.ARG_PID, position);
        newFragment.setArguments(args);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack so the user can navigate back
        transaction.replace(R.id.plugs, newFragment);
        transaction.addToBackStack(null);
        // Commit the transaction
        transaction.commit();
    }
}

[Buggy Hunk]
transaction.replace(R.id.plugs, newFragment);

[Patch]
transaction.replace(R.id.plugs_list, newFragment);

[Demonstration 3]

[Buggy Method]
@Override
public void onClick(View view) {
    if (listener != null) {
        listener.onFragmentInteraction(Constants.DAYS_FRAGMENT);
    }
}

[Buggy Hunk]
listener.onFragmentInteraction(Constants.DAYS_FRAGMENT);

[Patch]
listener.onFragmentInteraction(Constants.DAYS_FRAGMENT, new Bundle());