On Mon, Jan 19, 2009 at 8:57 PM, Jukka Zitting <jukka.zitt...@gmail.com> wrote:
> Hi,
>
> On Mon, Jan 19, 2009 at 9:45 PM, Niall Pemberton
> <niall.pember...@gmail.com> wrote:
>> What about using a (read-only?) ByteBuffer[1] rather than InputStream
>> to avoid the issue of implementations doing things with the
>> InputStream that they shouldn't?
>
> I'd like to avoid having the Detector API fix the specific number of
> prefix bytes that are available for content type detection. This is
> why I prefer using InputStream as the argument. It's simple enough to
> wrap a stream into a proxy that prevents an unknown detector from
> doing anything else than read from the stream.

But your API says "...the detector must only read up to a limited
number of bytes from the stream to avoid potentially unbounded memory
use for the buffer of a marked a stream." - with a ByteBuffer the
detector would be able to discover how many its allowed to read -
otherwise how are you going to prevent it going past the limit - throw
an exception? Potentially as well it could be much more efficient.

Niall

> prefix bytes that are available


> BR,
>
> Jukka Zitting
>

Reply via email to