class ReaderEntityProvider implements EntityProvider<Reader> {

    @Override
    public Reader readFrom(Class<Reader> type, Type genericType, Annotation[] annotations, MediaType mediaType,
                           MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
        ApplicationContext context = ApplicationContext.getCurrent();
        if (context.isAsynchronous()) {
            int bufferSize = context.getEverrestConfiguration().getMaxBufferSize();
            return new InputStreamReader(IOHelper.bufferStream(entityStream, bufferSize), getCharsetOrUtf8(mediaType));
        }

        return new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType));
    }

}