Hi,
i stumbled over this as well some time ago. The Javadoc says this exception
happens when the ByteBuffer isn't backed by an accessible array, my finding
was it isn't guaranteed in any way it is - better do not rely on that
method.
Fortunately you can easily rewrite your code to
int len = in.remaining();
//(i do think your usage of limit() is not what you intend to do)
byte[] stream = new byte[len];
in.get(stream , 0, in.remaining());
hope that helps.
regards,
christian!
On 2/19/08, Brenno Hayden <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I am having a difficulty in mke this cast? Can I do something? Some tip ?
>
> *code*
>
> ByteArrayDecoder extends CumulativeProtocolDecoder {
>
> protected boolean doDecode(IoSession session, ByteBuffer in,
> ProtocolDecoderOutput out) throws Exception {
> if (in instanceof ByteBuffer) {
> int len = in.limit();
> byte[] stream = new byte[len];
> //TODO
> stream = in.array(); // Why ?
> out.write(stream);
> return true;
> }else {
> return false.
> }
> }
>
> *console*:
>
> org.apache.mina.filter.codec.ProtocolDecoderException:
> java.lang.UnsupportedOperationException
>
>
>
> Thanks
>
>
> --
> ________________________
> Brenno Hayden F. Dantas
>