[Demonstration 1]

[Buggy Method]
@Override
public Indent cancelDeal(Indent indent, String userId) {
    Indent updatedIndent = null;
    if (indent != null) {
        if (!IndentStatusEnum.UNPAID.value().equals(indent.getStatus())) {
            throw new ServiceWarningException("Can only cancel un-paid indent", MessageKeys.CAN_ONLY_CANCEL_UNPAID_INDENT);
        }
        if (!indent.getUserId().equals(userId) || !indent.getSellerId().equals(userId)) {
            throw new ServiceWarningException("Can only cancel your own indent", MessageKeys.CAN_ONLY_CANCEL_YOUR_OWN_INDENT);
        }
        indent.setStatus(IndentStatusEnum.CANCELLED.value());
        updatedIndent = update(indent);
    }
    return updatedIndent;
}

[Buggy Hunk]
if (!indent.getUserId().equals(userId) || !indent.getSellerId().equals(userId)) {

[Patch]
if (!indent.getUserId().equals(userId) && !indent.getSellerId().equals(userId)) {

[Demonstration 2]

[Buggy Method]
protected void removeSSRC(long ssrc) {
    //find the ssrc
    int index = -1;
    if (ssrcList == null || ssrcList.length == 0) {
        //list is already empty so there's nothing to do.
        return;
    }
    for (int i = 0; i < ssrcList.length; i++) {
        if (ssrcList[i] == ssrc) {
            index = i;
            break;
        }
    }
    if (index < 0 || index >= ssrcList.length) {
        //the ssrc we are trying to remove is not in the list so there's
        //nothing to do.
        return;
    }
    //if we get here and the list has a single element this would mean we
    //simply need to empty it as the only element is the one we are removing
    if (ssrcList.length == 1) {
        setSsrcList(null);
        return;
    }
    long[] newSsrcList = new long[ssrcList.length];
    System.arraycopy(ssrcList, 0, newSsrcList, 0, index);
    if (index < ssrcList.length - 1) {
        System.arraycopy(ssrcList, index + 1, newSsrcList, index, ssrcList.length - index - 1);
    }
    setSsrcList(newSsrcList);
}

[Buggy Hunk]
long[] newSsrcList = new long[ssrcList.length];

[Patch]
long[] newSsrcList = new long[ssrcList.length - 1];

[Demonstration 3]

[Buggy Method]
private void showTrackDialog() {
    final Dialog dialog = new Dialog(MainActivity.this);
    dialog.setTitle(R.string.title_newtrack);
    dialog.setContentView(R.layout.newtrack_dialog);
    final EditText editText = (EditText) dialog.findViewById(R.id.newtrack_edittext);
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss", Locale.getDefault());
    sdf.setTimeZone(TimeZone.getDefault());
    final String dateSuffix = sdf.format(Calendar.getInstance().getTime());
    final String autoName = "Auto_" + dateSuffix;
    editText.setText(autoName);
    dialog.show();
    final Button submit = (Button) dialog.findViewById(R.id.newtrack_button_submit);
    submit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String trackName = editText.getText().toString();
            if (trackName.length() == 0) {
                return;
            }
            db.newTrack(trackName);
            LoggerService.lastUpdateRealtime(0);
            updateTrackLabel(trackName);
            updateStatus();
            dialog.cancel();
        }
    });
    final Button cancel = (Button) dialog.findViewById(R.id.newtrack_button_cancel);
    cancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.cancel();
        }
    });
}

[Buggy Hunk]
LoggerService.lastUpdateRealtime(0);

[Patch]
LoggerService.resetUpdateRealtime();