[Demonstration 1]

[Buggy Method]
private boolean fillCostAndSizeArray() {
    GPDLogger.info(this, String.format("Filling the cost array."));
    Stopwatch stopwatch;
    List<Query> queries = workload.getQueries();
    if (useRegression || sizeLimit > 0) {
        extractor.initialize(sampleDBs, dbInfo.getTargetDBName(), schema);
    }
    // fill cost array from each sample database.
    for (int d = 0; d < numSampleDBs; ++d) {
        String dbName = sampleDBs.get(d).getDbName();
        Statement stmt;
        try {
            conn.setCatalog(dbName);
            stmt = conn.createStatement();
        } catch (SQLException e) {
            GPDLogger.error(this, "A SQLException has been caught.");
            e.printStackTrace();
            ;
            return false;
        }
        for (int j = 0; j < configurations.size(); ++j) {
            List<Structure> configuration = configurations.get(j);
            // build structures
            GPDLogger.info(this, String.format("Building structures for configuration #%d out of %d.", j + 1, configurations.size()));
            for (Structure s : configuration) {
                s.create(conn);
                extractor.addTrainingDataForSize(dbName, schema, s);
            }
            GPDLogger.info(this, String.format("Running queries for configuration #%d out of %d.", j + 1, configurations.size()));
            for (int i = 0; i < queries.size(); ++i) {
                Query q = queries.get(i);
                stopwatch = Stopwatch.createStarted();
                boolean isTimedOut = false;
                try {
                    stmt.setQueryTimeout(GPDMain.userInput.getSetting().getQueryTimeout());
                    stmt.execute(q.getContent());
                } catch (SQLException e) {
                    GPDLogger.info(this, String.format("Query #%d has been timed out. Assigning " + "maximum cost.", i));
                    isTimedOut = true;
                }
                double queryTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
                // when query times out, we assign INT_MAX to its cost.
                if (isTimedOut) {
                    rawCostArray[d][i][j] = (long) Integer.MAX_VALUE;
                } else {
                    rawCostArray[d][i][j] = (long) queryTime;
                }
                extractor.addTrainingData(dbName, schema, q, j, queryTime);
            }
            // remove structures
            GPDLogger.info(this, String.format("Removing structures for configuration #%d out of %d.", j + 1, configurations.size()));
            for (Structure s : configuration) {
                s.drop(conn);
            }
        }
    }
    GPDSMORegression sr = new GPDSMORegression();
    if (useRegression) {
        if (!sr.build(extractor.getTrainData())) {
            return false;
        }
    }
    for (int j = 0; j < configurations.size(); ++j) {
        for (int i = 0; i < queries.size(); ++i) {
            if (useRegression) {
                Query q = queries.get(i);
                Instance testInstance = extractor.getTestInstance(dbInfo.getTargetDBName(), schema, q, j);
                costArray[i][j] = sr.regress(testInstance);
            } else {
                long total = 0;
                for (int d = 0; d < numSampleDBs; ++d) {
                    total += rawCostArray[d][i][j];
                }
                costArray[i][j] = total / numSampleDBs;
            }
        }
    }
    return true;
}

[Buggy Hunk]
e.printStackTrace();;

[Patch]
e.printStackTrace();

[Demonstration 2]

[Buggy Method]
@Override
public void send(NotificationType type, Recipient recipient, String attachment) throws MessagingException, IOException {
    final String subject = env.getProperty(type.getSubject());
    final String text = MessageFormat.format(env.getProperty(type.getText()), recipient.getAccountName());
    MimeMessage message = mailSender.createMimeMessage();
    MimeMessageHelper helper = new MimeMessageHelper(message, true);
    helper.setTo(recipient.getEmail());
    helper.setSubject(subject);
    helper.setText(text);
    if (!Strings.isNullOrEmpty(attachment)) {
        helper.addAttachment(env.getProperty(type.getAttachment()), new ByteArrayResource(attachment.getBytes()));
    }
    mailSender.send(message);
    log.info("An email {} notification has been send to {}", type, recipient.getEmail());
}

[Buggy Hunk]
if (!Strings.isNullOrEmpty(attachment)) {

[Patch]
if (StringUtils.hasLength(attachment)) {

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