[Demonstration 1]

[Buggy Method]
@Override
protected URLConnection openConnection(URL u) throws IOException {
    return new URLConnection(u) {

        @Override
        public void connect() throws IOException {
        }

        @Override
        public InputStream getInputStream() throws IOException {
            return new FileInputStream(new File(tempDir, name));
        }
    };
}

[Buggy Hunk]
return new FileInputStream(new File(tempDir, name));

[Patch]
return new FileInputStream(file);

[Demonstration 2]

[Buggy Method]
public static byte[] getByteArrayFromInputStream(InputStream in, int bufferSize) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream() {

        @Override
        public byte[] toByteArray() {
            return this.buf;
        }
    };
    try {
        LocalServer.copyIO(in, baos, bufferSize);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    return baos.toByteArray();
}

[Buggy Hunk]
ByteArrayOutputStream baos = new ByteArrayOutputStream() { @Override public byte[] toByteArray() { return this.buf; } };

[Patch]
ByteArrayOutputStream baos = new ByteArrayOutputStream();

[Demonstration 3]

[Buggy Method]
public void login() throws IOException, InvalidCredentialsException, LoginException, IntranetException {
    Boolean success = false;
    // Post request parameters
    StringBuilder builder = new StringBuilder();
    builder.append("loginuser=").append(this.username).append("&loginpassword=").append(this.password).append("&loginschool=").append(this.school);
    String urlParameters = builder.toString();
    byte[] postData = urlParameters.getBytes(Charset.forName("UTF-8"));
    int postDataLength = postData.length;
    /*System.out.println("\nSending 'POST' request to URL : " + URL);
		System.out.println("Post parameters : " + urlParameters);*/
    // WebRequest
    HttpsURLConnection con = this.openUrlConnection(URL, "POST");
    con.setRequestProperty("Content-Length", Integer.toString(postDataLength));
    con.setDoOutput(true);
    con.setDoInput(true);
    con.setInstanceFollowRedirects(false);
    con.setUseCaches(true);
    // Write Post Data
    DataOutputStream wr = new DataOutputStream(con.getOutputStream());
    wr.write(postData);
    wr.flush();
    wr.close();
    int responseCode = con.getResponseCode();
    if (responseCode == 500) {
        throw new LoginException("Invalid School or WebError");
    } else if (responseCode == 200) {
        throw new InvalidCredentialsException();
    } else if (responseCode != 302) {
    }
    this.readUrlConnectionResponse(con);
    // Read Cookies
    String headerName = null;
    for (int i = 1; (headerName = con.getHeaderFieldKey(i)) != null; i++) {
        if (headerName.equals("Set-Cookie")) {
            String cookie = con.getHeaderField(i);
            System.out.println("Login Cookie: " + cookie);
            String[] parts = cookie.split(";");
            String[] parts2 = parts[0].split("=");
            if (parts2[0].equals("sturmsession"))
                this.sessionid = parts2[1];
            if (parts2[0].equals("sturmuser"))
                success = true;
        }
    }
    if (!success)
        throw new IntranetException();
    // Get userid
    this.userid = Integer.parseInt(Jsoup.parse(this.getRequest(URL + "/" + school)).select("a[onclick][title][href]").first().attr("onclick").split("\\(")[1].split(",")[0].toString());
}

[Buggy Hunk]
this.userid = Integer.parseInt(Jsoup.parse(this.getRequest(URL + "/" +  school)).select("a[onclick][title][href]").first().attr("onclick").split("\\(")[1].split(",")[0].toString());

[Patch]
this.userid = Integer.parseInt(Jsoup.parse(this.getRequest(URL + "/" +  school)).select("a[onclick][title][href]").first().attr("onclick").split("\\(")[1].split(",")[0].toString().replace("\'", ""));