[Demonstration 1]

[Buggy Method]
public static PuValue unpackPrimitive(MessageUnpacker unpacker, MessageFormat format) throws IOException {
    if (unpacker == null || format == null) {
        throw new NullPointerException("Both unpacker and format must be not-null");
    }
    Value value = unpacker.unpackValue();
    switch(format) {
        case NIL:
        case NEVER_USED:
            return null;
        case BOOLEAN:
            return new PuValue(value.asBooleanValue().getBoolean());
        case FLOAT32:
            return new PuValue(value.asNumberValue().toFloat());
        case FLOAT64:
            return new PuValue(value.asNumberValue().toDouble());
        case STR8:
        case STR16:
        case STR32:
        case FIXSTR:
            return new PuValue(value.asStringValue().toString());
        case UINT8:
        case INT16:
        case NEGFIXINT:
            return new PuValue(value.asNumberValue().toShort());
        case INT32:
        case UINT16:
            return new PuValue(value.asNumberValue().toInt());
        case INT64:
        case UINT32:
        case UINT64:
            return new PuValue(value.asNumberValue().toLong());
        case INT8:
        case POSFIXINT:
            return new PuValue(value.asNumberValue().toByte());
        default:
            throw new UnsupportedTypeException("Expected primitive value");
    }
}

[Buggy Hunk]
throw new UnsupportedTypeException("Expected primitive value");

[Patch]
throw new UnsupportedTypeException("Expected primitive value, got " + format);

[Demonstration 2]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));

[Demonstration 3]

[Buggy Method]
public static String fireISBNRequest(ISBN isbn) {
    String url = "https://www.googleapis.com/books/v1/volumes";
    Charset charset = StandardCharsets.UTF_8;
    String paramName = "q";
    String param = "ISBN";
    String query = "";
    try {
        query = String.format(paramName + "=%s:%s", URLEncoder.encode(param, charset.toString()), isbn.toString());
        return fireRequest(new URL(url + "?" + query));
    } catch (UnsupportedEncodingException e) {
        // Should not occur as the encoding is set to UTF-8
        new ExceptionDialog(Error.URL_FORMAT_ERROR, e);
    } catch (MalformedURLException e) {
        new ExceptionDialog(Error.URL_INVALID_ERROR, e);
    } catch (IOException e) {
        new ExceptionDialog(Error.ISBN_NOT_FOUND, e);
    }
    return ERROR;
}

[Buggy Hunk]
new ExceptionDialog(Error.ISBN_NOT_FOUND, e);

[Patch]
new ExceptionDialog(Error.NO_CONNECTION_ERROR, e, "Die folgende ISBN konnte nicht gefunden werden:" + isbn.toString() + "  Es besteht keine Internetverbindung.");