[Demonstration 1]

[Buggy Method]
public static File jarFile(Class sampleClass) {
    try {
        CodeSource codeSource = sampleClass.getProtectionDomain().getCodeSource();
        if (codeSource != null && codeSource.getLocation() != null) {
            String fileName = URLDecoder.decode(codeSource.getLocation().getFile(), "UTF-8");
            return new File(FilenameUtils.getName(fileName));
        }
        String resourcePath = sampleClass.getName();
        resourcePath = resourcePath.replace('.', '/') + ".class";
        URL url = computeUrl(resourcePath, true);
        String urlPath = url.toString();
        if (urlPath.startsWith("jar:")) {
            urlPath = urlPath.substring(4);
        }
        if (urlPath.startsWith("file:")) {
            urlPath = urlPath.substring(5);
        }
        urlPath = prefixOrSuffix(urlPath, "!", true);
        urlPath = URLDecoder.decode(urlPath, "UTF-8");
        File file = new File(urlPath);
        if (urlPath.endsWith(".jar") && file.exists() && file.isFile()) {
            return file;
        }
    } catch (Exception e) {
    }
    return null;
}

[Buggy Hunk]
return new File(FilenameUtils.getName(fileName));

[Patch]
return new File(fileName);

[Demonstration 2]

[Buggy Method]
@CrossOrigin(origins = { "http://s3-us-west-2.amazonaws.com", "http://localhost:8080" })
@RequestMapping(path = "/emails", method = RequestMethod.GET)
public List<Email> getEmailData(UriComponentsBuilder uriBuilder) throws IOException {
    logger.debug("Beginning call to get email data");
    List<Email> emails = emailService.getAll();
    emails.forEach(e -> {
        e.getAttachments().forEach(a -> {
            a.setUrl(uriBuilder.path(String.format("/attachments/%s", a.getKey())).toUriString());
        });
    });
    return emails;
}

[Buggy Hunk]
a.setUrl(uriBuilder.path(String.format("/attachments/%s", a.getKey())).toUriString());

[Patch]
a.setUrl(uriBuilder.cloneBuilder().path(String.format("/attachments/%s", a.getKey())).build().toUriString());

[Demonstration 3]

[Buggy Method]
public String[] parameterValues(HttpServletRequest request) {
    String urlPath = request.getRequestURI().substring(request.getContextPath().length());
    return urlPath.split("/");
}

[Buggy Hunk]
return urlPath.split("/");

[Patch]
return urlPath.split(Url.PATH_SEPERATOR);