[Demonstration 1]

[Buggy Method]
public static void main(String[] args) {
    JettisonMappedXmlDriver xmlDriver = new JettisonMappedXmlDriver();
    XStream xstream = new XStream(xmlDriver);
    MockMessage mock1 = new MockMessage();
    MockMessage mock2 = new MockMessage();
    MockMessageOther mock3 = new MockMessageOther();
    List messages = new ArrayList();
    messages.add(mock1);
    messages.add(mock2);
    messages.add(mock3);
    String jsonString = xstream.toXML(messages);
    //JSON list format is non-intuitive single element array with class name fields
    System.out.println(jsonString);
    List xstreamJSONUnmarshalledMessages = (List) xstream.fromXML(jsonString);
    //This will print 3 messages unmarshalled
    System.out.println("XStream format JSON Number of messages unmarshalled: " + xstreamJSONUnmarshalledMessages.size());
    //Attempt to deserialize a reasonable looking JSON string
    String jsonTest = "{" + "\"list\" : [" + "{" + "\"MockMessage\" : {" + "\"val\" : 1" + "}" + "}, {" + "\"MockMessage\" : {" + "\"val\" : 1" + "}" + "}, {" + "\"MockMessageOther\" : {" + "\"otherVal\" : 1" + "}" + "} ]" + "};";
    List unmarshalledMessages = (List) xstream.fromXML(jsonTest);
    //We expect 3 messages but XStream only deserializes one
    System.out.println("Normal format JSON Number of messages unmarshalled: " + unmarshalledMessages.size());
}

[Buggy Hunk]
MockMessageOther mock3 = new MockMessageOther();

[Patch]
MockMessage mock3 = new MockMessage();

[Demonstration 2]

[Buggy Method]
@Override
protected HttpsURLConnection getConnectionFromUrl(URL url) throws IOException {
    HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
    connection.setReadTimeout(mReadTimeout);
    connection.setConnectTimeout(mConnectTimeout);
    connection.setRequestMethod("POST");
    connection.setFixedLengthStreamingMode(mBody.getBytes().length);
    connection.setRequestProperty("Content-Type", "application/json");
    connection.setDoOutput(true);
    return connection;
}

[Buggy Hunk]
connection.setFixedLengthStreamingMode(mBody.getBytes().length);

[Patch]
connection.setFixedLengthStreamingMode(mBody.getBytes("UTF-8").length);

[Demonstration 3]

[Buggy Method]
@RequestMapping(value = "/addAuthor", method = RequestMethod.POST, consumes = "application/json")
@ResponseBody
public String addAuthor(@RequestBody Author author, Locale locale, Model model) {
    try {
        adminService.addAuthor(author);
        return "Author added succesfully";
    } catch (Exception e) {
        e.printStackTrace();
        return "Author add failed. Reason: " + e.getMessage();
    }
}

[Buggy Hunk]
public @ResponseBody String addAuthor(@RequestBody Author author,

[Patch]
public  String addAuthor(@RequestBody Author author,