[Demonstration 1]

[Buggy Method]
private MimeMessage write(String[] recipients, String replyTo, String subject, String plainText, String htmlText, int priority, DataSource... attachments) throws MessagingException {
    MimeMessage message = new MimeMessage(session);
    message.setFrom(from);
    InternetAddress[] addresses = new InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++) {
        addresses[i] = new InternetAddress(recipients[i]);
    }
    message.setRecipients(Message.RecipientType.TO, addresses);
    if (replyTo != null) {
        message.setReplyTo(new Address[] { new InternetAddress(replyTo) });
    }
    message.setSubject(subject);
    message.setHeader("X-Priority", "" + priority);
    if (attachments.length == 0) {
        setText(message, plainText, htmlText);
    } else {
        MimeMultipart multipart = new MimeMultipart();
        MimeBodyPart bodyPart = new MimeBodyPart();
        setText(bodyPart, plainText, htmlText);
        multipart.addBodyPart(bodyPart);
        for (DataSource attachment : attachments) {
            bodyPart = new MimeBodyPart();
            bodyPart.setFileName(attachment.getName());
            bodyPart.setDataHandler(new DataHandler(attachment));
            multipart.addBodyPart(bodyPart);
        }
        message.setContent(multipart);
    }
    message.saveChanges();
    return message;
}

[Buggy Hunk]
message.setSubject(subject);

[Patch]
message.setSubject(subject, "utf-8");

[Demonstration 2]

[Buggy Method]
public void send(Email from, Email to, String subject, String text) throws EmailNotSentException {
    SendGrid.Email email = new SendGrid.Email();
    email.addTo(to.getAddress());
    email.setFrom(from.getAddress());
    email.setSubject(subject);
    email.setText(text);
    try {
        SendGrid.Response response = sg.send(email);
        System.out.println(response.getMessage());
        if (!response.getMessage().equals("success"))
            throw new EmailNotSentException();
    } catch (SendGridException e) {
        System.err.println(e);
        throw new EmailNotSentException();
    }
}

[Buggy Hunk]
if(!response.getMessage().equals("success"))

[Patch]
if(!response.getMessage().equals("{\"message\":\"success\"}"))

[Demonstration 3]

[Buggy Method]
private SqlFluent add(String word) {
    if (mBuilder.length() == 0)
        mBuilder.append(' ');
    mBuilder.append(word);
    return this;
}

[Buggy Hunk]
if(mBuilder.length() == 0)

[Patch]
if(mBuilder.length() != 0)