[Demonstration 1]

[Buggy Method]
public Exception setResponse(HttpServletRequest request, HttpServletResponse response, Object obj, Exception ex) {
    // get the status
    HttpStatus status = EXCEPTION_MAP.get(ex.getClass());
    if (status == null) {
        //if this is an unexpected exception, set the code to internal server error.
        status = HttpStatus.INTERNAL_SERVER_ERROR;
    }
    logException(request, response, obj, status, ex);
    response.setStatus(status.value());
    response.addHeader("ErrorMessage", ex.getMessage());
    response.setContentType(MediaType.APPLICATION_JSON.getType());
    return ex;
}

[Buggy Hunk]
response.setContentType(MediaType.APPLICATION_JSON.getType());

[Patch]
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);

[Demonstration 2]

[Buggy Method]
@Override
protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatus status, WebRequest request) {
    logger.warn(ex.getMessage(), ex);
    return super.handleExceptionInternal(ex, body, headers, status, request);
}

[Buggy Hunk]
logger.warn(ex.getMessage(), ex);

[Patch]
log.warn(ex.getMessage(), ex);

[Demonstration 3]

[Buggy Method]
protected boolean allowMetadataOperations(File file, NodeRef node) {
    if (!enabled) {
        LOG.debug("Metadata writing disabled by configuration (pdfapilot.metadatawriter.enabled). Aborting");
        return false;
    }
    String extension = FilenameUtils.getExtension(file.getName());
    String sizeLimitProperty = SIZE_LIMIT_PROPERTY_PREFIX + extension + SIZE_LIMIT_PROPERTY_SUFFIX;
    String sizeLimit = globalProperties.getProperty(sizeLimitProperty);
    if (sizeLimit == null || sizeLimit.length() == 0) {
        sizeLimit = globalProperties.getProperty(SIZE_LIMIT_PROPERTY_DEFAULT);
    }
    if (sizeLimit == null || sizeLimit.length() == 0) {
        LOG.warn("No size limit found. Allowing. File name: " + file.getName());
    } else {
        long sizeLimitLong = Long.valueOf(sizeLimit) * 1024;
        if (file.length() > sizeLimitLong) {
            LOG.warn("File length is above the limit for node " + node + ". File name: " + file.getName() + " Denying.");
            return false;
        } else if (LOG.isDebugEnabled()) {
            LOG.debug("Allowing, size is below limit for node " + node + ". File name: " + file.getName());
        }
    }
    return true;
}

[Buggy Hunk]
LOG.warn("No size limit found. Allowing. File name: " + file.getName());

[Patch]
LOG.trace("No size limit found. Allowing. File name: " + file.getName());