[Demonstration 1]

[Buggy Method]
public static void main(String[] args) throws InpExc {
    IUserDAO iDAO = new UserDAODiscImpl();
    UserDTO newUser = new UserDTO();
    printUsers(iDAO);
    //TODO test new fields...
    newUser.setIni("test");
    newUser.addRole("Admin");
    newUser.setUserName("testName");
    newUser.setUserId(0);
    try {
        iDAO.createUser(newUser);
    } catch (DALException e) {
        e.printStackTrace();
    }
    try {
        iDAO.createUser(newUser);
    } catch (DALException e1) {
        System.out.println("User already existed - OK");
    }
    newUser.setUserId(1);
    newUser.setUserName("2ND user");
    try {
        iDAO.createUser(newUser);
    } catch (DALException e1) {
        e1.printStackTrace();
    }
    printUsers(iDAO);
    newUser.setUserId(0);
    newUser.setUserName("ModifiedName");
    try {
        iDAO.updateUser(newUser);
    } catch (DALException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    printUsers(iDAO);
    try {
        iDAO.deleteUser(1);
    } catch (DALException e) {
        e.printStackTrace();
    }
    printUsers(iDAO);
}

[Buggy Hunk]
public static void main(String[] args) throws InpExc {

[Patch]
public static void main(String[] args) throws DALException{

[Demonstration 2]

[Buggy Method]
public List<Person> getfriends(String userid) {
    String querry = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>  " + "PREFIX foaf:<http://xmlns.com/foaf/0.1/>" + "PREFIX cv:<http://captsolo.net/semweb/resume/0.2/cv.rdf/>" + "PREFIX cvb:<http://captsolo.net/semweb/resume/0.2/base.rdf//>" + "PREFIX acc:<http://www.semanticdesktop.org/ontologies/2011/10/05/dao/v1.0/>" + "select Distinct ?bname ?c where  {" + "?person a foaf:Person. " + " ?person foaf:knows ?b. " + " ?b foaf:name ?bname. " + " ?c a foaf:Person; " + " foaf:name ?name " + " FILTER  (?person=<" + Constants.inputFileName + "#" + userid + "> && ?name=?bname ) } ";
    Model model = ModelFactory.createDefaultModel();
    InputStream in = FileManager.get().open(Constants.inputFileName);
    model.read(Constants.inputFileName, "");
    if (in == null) {
        throwException();
    }
    Query query = QueryFactory.create(querry);
    QueryExecution qe = QueryExecutionFactory.create(query, model);
    ResultSet results = qe.execSelect();
    List<String> varNames = results.getResultVars();
    String var1 = varNames.get(0);
    List<Person> result = new ArrayList<Person>();
    while (results.hasNext()) {
        QuerySolution binding = results.nextSolution();
        String pers = binding.get(var1).toString();
        Resource subj = (Resource) binding.get("c");
        String id;
        if (subj.getURI() != null && subj.getURI().contains(Constants.inputFileName)) {
            id = subj.getURI().substring((subj.getURI().indexOf("#") + 1));
            Person p = new Person();
            p.setUserId(id);
            p.setUserName(pers);
            result.add(p);
        }
    }
    qe.close();
    return result;
}

[Buggy Hunk]
p.setUserName(pers);

[Patch]
p.setName(pers);

[Demonstration 3]

[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));