[Demonstration 1]

[Buggy Method]
@Atomic
public void transitToConcludedState() {
    if (getAcademicServiceRequestSituationType() != AcademicServiceRequestSituationType.PROCESSING) {
        throw new DomainException("error.serviceRequests.ULisboaServiceRequest.invalid.changeState");
    }
    transitState(AcademicServiceRequestSituationType.CONCLUDED, ULisboaConstants.EMPTY_JUSTIFICATION.getContent());
    validate();
    //TODOJN create validator to check if has generated one time the document
    if (getServiceRequestType().getNotifyUponConclusion().booleanValue()) {
        sendConclusionNotification();
    }
}

[Buggy Hunk]
if (getServiceRequestType().getNotifyUponConclusion().booleanValue()) {

[Patch]
if (getServiceRequestType().isToNotifyUponConclusion()) {

[Demonstration 2]

[Buggy Method]
public void populateData() throws SQLException {
    int tmp = -1;
    TGSpreadConnection gsConnection = (TGSpreadConnection) getConnection();
    WorksheetFeed workSheetFeed = gsConnection.getWorksheetFeed();
    if (workSheetFeed == null) {
        throw new SQLException("Work sheet feed it not initialized properly and is null");
    }
    List<WorksheetEntry> workSheets = workSheetFeed.getEntries();
    for (WorksheetEntry workSheet : workSheets) {
        DataRow dataRow = null;
        TGSpreadFeedUtil feedUtil = new TGSpreadFeedUtil(gsConnection);
        CellFeed cellFeed = feedUtil.getCellFeed(workSheet);
        ColumnInfo[] headers = this.extractHeaders(workSheet);
        DataTable result = new FixedDataTable(workSheet.getTitle().getPlainText(), headers);
        for (CellEntry cell : cellFeed.getEntries()) {
            int rowId = TDriverUtil.getRowIndex(cell.getId());
            if (tmp != rowId && rowId != 1) {
                if (dataRow != null) {
                    result.addRow(this.fillUpEmptyCells(dataRow, headers));
                }
                dataRow = new DataRow(rowId - 1);
                tmp = rowId;
            }
            int columnId = TDriverUtil.getColumnIndex(cell.getId());
            if (columnId > headers.length) {
                continue;
            }
            if (rowId != 1 && dataRow != null) {
                DataCell dataCell = new DataCell(TDriverUtil.getColumnIndex(cell.getId()) - 1, cell.getContent().getType(), cell.getTextContent().getContent().getPlainText());
                dataRow.addCell(dataCell.getColumnId(), dataCell);
            }
        }
        /* adding the last row of the sheet */
        if (dataRow != null) {
            result.addRow(this.fillUpEmptyCells(dataRow, headers));
        }
        this.getData().put(result.getTableName(), result);
    }
}

[Buggy Hunk]
new DataCell(TDriverUtil.getColumnIndex(cell.getId()) - 1,

[Patch]
new DataCell(TDriverUtil.getColumnIndex(cell.getId()),

[Demonstration 3]

[Buggy Method]
public void setCORSHeaders(MessageContext messageContext, Resource selectedResource) {
    org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
    Map<String, String> headers = (Map) axis2MC.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    String requestOrigin = headers.get("Origin");
    messageContext.setProperty(APIConstants.CORSHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, getAllowedOrigins(requestOrigin));
    String allowedMethods = "";
    if (selectedResource != null) {
        for (String method : selectedResource.getMethods()) {
            allowedMethods += method + ",";
        }
        if (!allowedMethods.isEmpty()) {
            allowedMethods = allowedMethods.substring(0, allowedMethods.length() - 1);
        }
    } else {
        allowedMethods = Utils.getAllowedMethods();
    }
    if ("*".equals(allowHeaders)) {
        allowedMethods = headers.get("Access-Control-Request-Headers");
    }
    messageContext.setProperty(APIConstants.CORS_CONFIGURATION_ENABLED, Utils.isCORSEnabled());
    messageContext.setProperty(APIConstants.CORSHeaders.ACCESS_CONTROL_ALLOW_METHODS, allowedMethods);
    messageContext.setProperty(APIConstants.CORSHeaders.ACCESS_CONTROL_ALLOW_HEADERS, allowHeaders);
}

[Buggy Hunk]
allowedMethods = headers.get("Access-Control-Request-Headers");

[Patch]
allowHeaders = headers.get("Access-Control-Request-Headers");