<commit_before>package io.quarkus.rest.runtime.providers.serialisers.jsonb;

import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.ws.rs.Consumes;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.Provider;

import io.quarkus.arc.Arc;
import io.quarkus.arc.InstanceHandle;

@Provider
@Consumes({ "application/json", "application/*+json", "text/json" })
public class JsonbMessageBodyReader implements MessageBodyReader<Object> {

    private final Jsonb json;

    public JsonbMessageBodyReader() {
        InstanceHandle<Jsonb> jsonbInstanceHandle = Arc.container().instance(Jsonb.class);
        if (jsonbInstanceHandle.isAvailable()) {
            this.json = jsonbInstanceHandle.get();
        } else {
            this.json = JsonbBuilder.create();
        }
    }

    @Override
    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
        return true;
    }

    @Override
    public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
            MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
        return json.fromJson(entityStream, genericType);
    }
}<commit_msg>Ensure that Jsonb deserialization works whether a generic type exists or not<commit_after>package io.quarkus.rest.runtime.providers.serialisers.jsonb;

import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.ws.rs.Consumes;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.Provider;

import io.quarkus.arc.Arc;
import io.quarkus.arc.InstanceHandle;

@Provider
@Consumes({ "application/json", "application/*+json", "text/json" })
public class JsonbMessageBodyReader implements MessageBodyReader<Object> {

    private final Jsonb json;

    public JsonbMessageBodyReader() {
        InstanceHandle<Jsonb> jsonbInstanceHandle = Arc.container().instance(Jsonb.class);
        if (jsonbInstanceHandle.isAvailable()) {
            this.json = jsonbInstanceHandle.get();
        } else {
            this.json = JsonbBuilder.create();
        }
    }

    @Override
    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
        return true;
    }

    @Override
    public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
            MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
        Type runtimeType = genericType != null ? genericType : type;
        return json.fromJson(entityStream, runtimeType);
    }
}
{'fraction_non_alphanumeric': 0.1044776119402985, 'fraction_numerical': 0.0, 'mean_word_length': 4.172025723472669, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1925471', 'n_tokens_mistral': 926, 'n_tokens_neox': 907, 'n_words': 199}