Search in sources :

Example 1 with NonBlockingInputFeeder

use of com.fasterxml.jackson.core.async.NonBlockingInputFeeder in project servicetalk by apple.

the class JacksonSerializationProvider method newDeserializer.

private static <T> StreamingDeserializer<T> newDeserializer(ObjectReader reader) {
    final JsonFactory factory = reader.getFactory();
    final JsonParser parser;
    try {
        // TODO(scott): ByteBufferFeeder is currently not supported by jackson, and the current API throws
        // UnsupportedOperationException if not supported. When jackson does support two NonBlockingInputFeeder
        // types we need an approach which doesn't involve catching UnsupportedOperationException to try to get
        // ByteBufferFeeder and then ByteArrayFeeder.
        parser = factory.createNonBlockingByteArrayParser();
    } catch (IOException e) {
        throw new IllegalArgumentException("parser initialization error for factory: " + factory, e);
    }
    NonBlockingInputFeeder rawFeeder = parser.getNonBlockingInputFeeder();
    if (rawFeeder instanceof ByteBufferFeeder) {
        return new ByteBufferJacksonDeserializer<>(reader, parser, (ByteBufferFeeder) rawFeeder);
    }
    if (rawFeeder instanceof ByteArrayFeeder) {
        return new ByteArrayJacksonDeserializer<>(reader, parser, (ByteArrayFeeder) rawFeeder);
    }
    throw new IllegalArgumentException("unsupported feeder type: " + rawFeeder);
}
Also used : JsonFactory(com.fasterxml.jackson.core.JsonFactory) NonBlockingInputFeeder(com.fasterxml.jackson.core.async.NonBlockingInputFeeder) ByteBufferFeeder(com.fasterxml.jackson.core.async.ByteBufferFeeder) IOException(java.io.IOException) ByteArrayFeeder(com.fasterxml.jackson.core.async.ByteArrayFeeder) JsonParser(com.fasterxml.jackson.core.JsonParser)

Aggregations

JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonParser (com.fasterxml.jackson.core.JsonParser)1 ByteArrayFeeder (com.fasterxml.jackson.core.async.ByteArrayFeeder)1 ByteBufferFeeder (com.fasterxml.jackson.core.async.ByteBufferFeeder)1 NonBlockingInputFeeder (com.fasterxml.jackson.core.async.NonBlockingInputFeeder)1 IOException (java.io.IOException)1