[Demonstration 1]

[Buggy Method]
public void handleMessage(final Message message) throws Fault {
    String name = null;
    String password = null;
    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
    if (policy != null) {
        name = policy.getUserName();
        password = policy.getPassword();
    } else {
        // try the UsernameToken
        SecurityToken token = message.get(SecurityToken.class);
        if (token != null && token.getTokenType() == TokenType.UsernameToken) {
            UsernameToken ut = (UsernameToken) token;
            name = ut.getName();
            password = ut.getPassword();
        }
    }
    if (name == null || password == null) {
        throw new AuthenticationException("Authentication required but no user or password was supplied");
    }
    try {
        CallbackHandler handler = getCallbackHandler(name, password);
        LoginContext ctx = new LoginContext(getContextName(), null, handler, loginConfig);
        ctx.login();
        Subject subject = ctx.getSubject();
        message.put(SecurityContext.class, createSecurityContext(name, subject));
        // Run the further chain in the context of this subject.
        // This allows other code to retrieve the subject using pure JAAS
        if (useDoAs) {
            Subject.doAs(subject, new PrivilegedAction<Void>() {

                @Override
                public Void run() {
                    InterceptorChain chain = message.getInterceptorChain();
                    if (chain != null) {
                        chain.doIntercept(message);
                    }
                    return null;
                }
            });
        }
    } catch (LoginException ex) {
        String errorMessage = "Authentication failed for user " + name + " : " + ex.getMessage();
        LOG.fine(errorMessage);
        if (reportFault) {
            throw new AuthenticationException(errorMessage);
        } else {
            throw new AuthenticationException("Authentication failed (details can be found in server log)");
        }
    }
}

[Buggy Hunk]
if (chain != null) {

[Patch]
if (chain != null && !JAASLoginInterceptor.this.suppressChainProcessing) {

[Demonstration 2]

[Buggy Method]
void transform(Point2D[] points, int start, int count) {
    int n = Math.min(points.length, start + count);
    for (int i = count; i < n; i++) {
        transform(points[i], points[i]);
    }
}

[Buggy Hunk]
for (int i = count; i < n; i++) {

[Patch]
for (int i = start; i < n; i++) {

[Demonstration 3]

[Buggy Method]
public boolean login(String email, String password) {
    Serializable authenticate = securityService.authenticate(email, password);
    refreshLoginStatus();
    if (null != authenticate) {
        sessionId = authenticate;
        return true;
    }
    sessionId = null;
    return false;
}

[Buggy Hunk]
Serializable authenticate = securityService.authenticate(email, password);

[Patch]
Serializable authenticate = securityService.authenticate(password, email);