[Demonstration 1]

[Buggy Method]
public ArrayList<Profilo> queryRicercaProfilo(String nome, String cognome, String email) {
    Connection connection = null;
    Statement statement = null;
    try {
        connection = DBManager.getInstance().getConnection();
        statement = connection.createStatement();
    } catch (Exception e) {
        return null;
    }
    boolean n = false, c = false, e = false;
    if (nome != null && !nome.equals(""))
        n = true;
    if (cognome != null && !cognome.equals(""))
        c = true;
    if (email != null && !email.equals(""))
        e = true;
    ArrayList<Profilo> resultN = null, resultC = null, resultE = null;
    ArrayList<Account> resultD = new ArrayList<>();
    String query1 = "SELECT nome, cognome, dataNascita, foto, residenza, email FROM profilo WHERE ";
    String query2;
    String query3 = "SELECT email FROM account WHERE tipo = 'D' OR tipo = 'B' ";
    ResultSet rsD;
    ResultSet rs;
    try {
        rsD = statement.executeQuery(query3);
        while (rsD.next()) {
            Account a = new Account(rsD.getString(1), "");
            resultD.add(a);
        }
    } catch (Exception t) {
        return null;
    }
    if (e) {
        query2 = "email = '" + email + "'";
        try {
            rs = statement.executeQuery(query1 + query2);
            resultE = getParsedProfiles(rs);
        } catch (Exception t) {
            return null;
        }
        if (resultE.size() > 0 && resultD.size() > 0) {
            for (Profilo p1 : resultE) {
                for (Account p2 : resultD) {
                    if (cfrProfiloAccount(p1, p2))
                        resultE.remove(p1);
                }
            }
            return resultE;
        }
    }
    if (n) {
        query2 = "nome = '" + nome + "'";
        try {
            rs = statement.executeQuery(query1 + query2);
            resultN = getParsedProfiles(rs);
        } catch (Exception t) {
            t.printStackTrace();
            return null;
        }
        if (!c) {
            for (Profilo p1 : resultN) {
                for (Account p2 : resultD) {
                    if (cfrProfiloAccount(p1, p2))
                        resultN.remove(p1);
                }
            }
            return resultN;
        }
    }
    if (c) {
        query2 = "cognome = '" + cognome + "'";
        try {
            rs = statement.executeQuery(query1 + query2);
            resultC = getParsedProfiles(rs);
        } catch (Exception t) {
            return null;
        }
        if (!n) {
            for (Profilo p1 : resultC) {
                for (Account p2 : resultD) {
                    if (cfrProfiloAccount(p1, p2))
                        resultC.remove(p1);
                }
            }
            return resultC;
        }
    }
    ArrayList<Profilo> result = new ArrayList<>();
    for (Profilo p1 : resultN) {
        for (Profilo p2 : resultC) {
            if (cfrProfilo(p1, p2))
                result.add(p1);
        }
    }
    for (Profilo p1 : result) {
        for (Account p2 : resultD) {
            if (cfrProfiloAccount(p1, p2))
                result.remove(p1);
        }
    }
    return result;
}

[Buggy Hunk]
if(resultE.size() > 0 && resultD.size() > 0){

[Patch]
if(resultE.size() > 0){

[Demonstration 2]

[Buggy Method]
private static JGrabOptions parseOptions(String[] args) {
    if (args.length == 0) {
        return new JGrabOptions.StdIn();
    }
    if (args.length == 1) {
        if (args[0].equals("--daemon") || args[0].equals("-d")) {
            return new JGrabOptions.StdIn();
        }
        if (args[0].equals("--help") || args[0].equals("-h")) {
            return help();
        }
        if (args[0].equals("--version") || args[0].equals("-v")) {
            return version();
        }
    }
    String first = args[0];
    String[] rest = new String[args.length - 1];
    System.arraycopy(args, 1, rest, 0, rest.length);
    if (first.equals(SNIPPET_OPTION)) {
        String script = String.join(" ", rest);
        return new JGrabOptions.Snippet(script);
    }
    return new JGrabOptions.JavaFile(new File(first), rest);
}

[Buggy Hunk]
return new JGrabOptions.StdIn();

[Patch]
return new JGrabOptions.Daemon();

[Demonstration 3]

[Buggy Method]
@Override
public void onResponse(JSONArray response) {
    try {
        for (int i = 0; i < response.length(); i++) {
            JSONObject o = response.getJSONObject(i);
            Log.i(TAG, "Adding user " + o.get("name"));
            users.add("" + o.get("name"));
        }
        Log.i(TAG, "Successfully fetched users.");
    } catch (JSONException e) {
        Log.e(TAG, "Getting users failed with JSONException " + e.toString());
    }
}

[Buggy Hunk]
Log.e(TAG, "Getting users failed with JSONException " + e.toString());

[Patch]
Log.e(TAG, "Getting users failed with JSONException", e);