[Demonstration 1]

[Buggy Method]
@Util
public static void saveProfile(User user, String firstName, String lastName, String address, String address2, String city, String postalCode, String state, String emailCollege, String emailPersonal, String reasonForApplication, boolean isSubmitted) {
    // save user if modified
    if (!user.getFirstName().equals(firstName) || !user.getLastName().equals(lastName)) {
        user.setFirstName(firstName);
        user.setLastName(lastName);
        user.save();
    }
    // get profile if exists
    Profile profile = null;
    if (user.getProfile() == null) {
        profile = new Profile();
        user.setProfile(profile);
        profile.setUser(user);
    } else {
        profile = user.getProfile();
    }
    // save profile
    //profile.setDateOfBirth(dateOfBirth);
    profile.setAddress(address);
    profile.setAddress2(address2);
    profile.setCity(city);
    profile.setPostalCode(postalCode);
    profile.setState(state);
    profile.setEmailCollege(emailCollege);
    profile.setEmailPersonal(emailPersonal);
    profile.setReasonForApplication(reasonForApplication);
    if (isSubmitted) {
        profile.setApplicationStatus(ApplicationStatus.Pending);
    } else {
        profile.setApplicationStatus(ApplicationStatus.None);
    }
    profile.save();
}

[Buggy Hunk]
} else {

[Patch]
} else if (profile.getApplicationStatus() == null) {

[Demonstration 2]

[Buggy Method]
private Optional<StructuredDataMapper> findInheritedMapper(Class beanClass) {
    Optional<StructuredDataMapper> result = Optional.absent();
    for (Optional<StructuredDataMapper> structuredDataMapper : dataMapperMap.values()) {
        if (structuredDataMapper.isPresent() && structuredDataMapper.get().getType().isAssignableFrom(beanClass)) {
            if (result == null || result.get().getType().isAssignableFrom(structuredDataMapper.get().getType())) {
                result = structuredDataMapper;
            }
        }
    }
    dataMapperMap.put(beanClass, result);
    return result;
}

[Buggy Hunk]
if (result == null ||

[Patch]
if (!result.isPresent() ||

[Demonstration 3]

[Buggy Method]
@Override
public void setAnswered(boolean isAnswered) {
    super.setAnswered(true);
}

[Buggy Hunk]
super.setAnswered(true);

[Patch]
super.setAnswered(isAnswered);