[Demonstration 1]

[Buggy Method]
private UserAuthentication getOrCreateUser(App app, Authentication ldapAuth) throws IOException {
    if (ldapAuth == null) {
        return null;
    }
    UserAuthentication userAuth = null;
    User user = new User();
    InetOrgPerson profile = (InetOrgPerson) ldapAuth.getPrincipal();
    if (profile != null && profile.isEnabled() && profile.isAccountNonLocked() && profile.isAccountNonExpired()) {
        String ldapAccountId = profile.getUsername();
        String email = profile.getMail();
        String name = StringUtils.join(profile.getCn(), ", ");
        if (StringUtils.isBlank(email)) {
            logger.warn("Failed to create LDAP user '{}' with blank email.", ldapAccountId);
            return null;
        }
        user.setAppid(getAppid(app));
        user.setIdentifier(Config.LDAP_PREFIX.concat(ldapAccountId));
        user.setEmail(email);
        user = User.readUserForIdentifier(user);
        if (user == null) {
            //user is new
            user = new User();
            user.setActive(true);
            user.setAppid(getAppid(app));
            user.setEmail(StringUtils.isBlank(email) ? ldapAccountId + "@ldap.com" : email);
            user.setName(StringUtils.isBlank(name) ? "No Name" : name);
            user.setPassword(new UUID().toString());
            user.setIdentifier(Config.LDAP_PREFIX.concat(ldapAccountId));
            String id = user.create();
            if (id == null) {
                throw new AuthenticationServiceException("Authentication failed: cannot create new user.");
            }
        } else {
            boolean update = false;
            if (!StringUtils.isBlank(email) && !StringUtils.equals(user.getEmail(), email)) {
                user.setEmail(email);
                update = true;
            }
            if (update) {
                user.update();
            }
        }
        userAuth = new UserAuthentication(new AuthenticatedUserDetails(user));
    }
    return userAuth;
}

[Buggy Hunk]
logger.warn("Failed to create LDAP user '{}' with blank email.", ldapAccountId);

[Patch]
LOG.warn("Failed to create LDAP user '{}' with blank email.", ldapAccountId);

[Demonstration 2]

[Buggy Method]
public void addFollowing(User user) {
    if (mMapFollowing == null) {
        mMapFollowing = new HashMap<>();
    }
    if (mFollowingSet == null) {
        mFollowingSet = new HashSet<>();
    }
    if (user.id != null) {
        mMapFollowing.put(user.getUserId(), user);
    }
    if (user.username != null) {
        mFollowingSet.add(user.username.toLowerCase());
    }
}

[Buggy Hunk]
mMapFollowing.put(user.getUserId(), user);

[Patch]
mMapFollowing.put(user.id, user);

[Demonstration 3]

[Buggy Method]
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    fragmentManager = getFragmentManager();
    systemService = getSystemService(Context.DOWNLOAD_SERVICE);
    if (!VersionUpdate.checked) {
        VersionUpdate vUpdate = new VersionUpdate();
        vUpdate.execute();
    }
    setContentView(R.layout.activity_main);
    qCoeffView = initVariables(qCoeffView, R.id.qCoeff);
    lCoeffView = initVariables(lCoeffView, R.id.lCoeff);
    freeTermView = initVariables(freeTermView, R.id.freeTerm);
    discriminant = initVariables(discriminant, R.id.discriminant);
    root1Denominator = initVariables(root1Denominator, R.id.root1Denominator);
    root2Denominator = initVariables(root2Denominator, R.id.root2Denominator);
    root1Numerator = initVariables(root1Numerator, R.id.root1Numerator);
    root2Numerator = initVariables(root2Numerator, R.id.root2Numerator);
    b = initVariables(b, R.id.b);
    root1 = initVariables(root1, R.id.root1);
    root2 = initVariables(root2, R.id.root2);
}

[Buggy Hunk]
vUpdate.execute();

[Patch]
vUpdate.execute(fragmentManager);