[Demonstration 1]

[Buggy Method]
@Override
public Object getMessageNonBlocking() {
    CommTuple receivedCommTuple = receivedObjectQueue.poll();
    if (replyConnection == null)
        return null;
    replyConnection = receivedCommTuple.getConnection();
    return receivedCommTuple.getObj();
}

[Buggy Hunk]
if (replyConnection == null) return null;

[Patch]
if (receivedCommTuple == null) return null;

[Demonstration 2]

[Buggy Method]
public static LocalDate lastRegisteredDate(final Registration registration, final ExecutionYear executionYear) {
    final RegistrationState lastRegistrationState = registration.getLastRegistrationState(executionYear);
    if (lastRegistrationState == null) {
        return null;
    }
    if (!lastRegistrationState.isActive()) {
        return null;
    }
    final LocalDate stateDate = lastRegistrationState.getStateDate().toLocalDate();
    final LocalDate dateOnBeginExecutionYearCivilDate = new LocalDate(executionYear.getBeginCivilYear(), stateDate.getMonthOfYear(), stateDate.getDayOfMonth());
    final LocalDate dateOnEndExecutionYearCivilDate = new LocalDate(executionYear.getBeginCivilYear(), stateDate.getMonthOfYear(), stateDate.getDayOfMonth());
    if (executionYear.containsDate(dateOnBeginExecutionYearCivilDate)) {
        return dateOnBeginExecutionYearCivilDate;
    } else if (executionYear.containsDate(dateOnEndExecutionYearCivilDate)) {
        return dateOnEndExecutionYearCivilDate;
    }
    return null;
}

[Buggy Hunk]
new LocalDate(executionYear.getBeginCivilYear(), stateDate.getMonthOfYear(), stateDate.getDayOfMonth());

[Patch]
new LocalDate(executionYear.getEndCivilYear(), stateDate.getMonthOfYear(), stateDate.getDayOfMonth());

[Demonstration 3]

[Buggy Method]
@Override
public boolean retainAll(Collection<?> items) {
    boolean hasChanged = false;
    for (int i = size - 1; size >= 0; i--) {
        if (!items.contains(data[i])) {
            remove(i);
            hasChanged = true;
        }
    }
    return hasChanged;
}

[Buggy Hunk]
for (int i = size - 1; size >= 0; i--) {

[Patch]
for (int i = size - 1; i >= 0; i--) {