use of com.fasterxml.jackson.core.async.ByteBufferFeeder 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);
}
Aggregations