Re: [xSocket-develop] Fwd: i got an error with xSocket V1_2_1
Status: Inactive
Brought to you by:
grro
|
From: Gregor R. <gre...@go...> - 2008-01-18 10:46:21
|
Hi,
I updated the current trunk of V1.2 and 2.0 to throw an
IllegalArgumentException if the length is negative.
cheers
Gregor
2008/1/18, PyungMoon Oh <qud...@gm...>:
>
> i found it..
>
> in the below source code..remainingToExtract value was minus value..
>
>
> public LinkedList<ByteBuffer> extract(LinkedList<ByteBuffer> inOutBuffer,
> int length) throws IOException, BufferUnderflowException {
>
> LinkedList<ByteBuffer> result = new LinkedList<ByteBuffer>();
>
> int remainingToExtract = length;
> ByteBuffer buffer = null;
>
> do {
> // get the next buffer
> buffer = inOutBuffer.remove();
> if (buffer == null) {
> throw new BufferUnderflowException();
> }
>
> // can complete buffer be taken?
> int bufLength = buffer.limit() - buffer.position();
> if (remainingToExtract >= bufLength) {
> // write taken into out channel
> result.addLast(buffer);
> remainingToExtract -= bufLength;
>
> // .. no
> } else {
> int savedLimit = buffer.limit();
>
> // extract the takenable
> buffer.limit(buffer.position() + remainingToExtract);
> ByteBuffer leftPart = buffer.slice();
> result.addLast(leftPart);
> buffer.position(buffer.limit());
> buffer.limit(savedLimit);
> ByteBuffer rightPart = buffer.slice();
> inOutBuffer.addFirst(rightPart);
> break;
> }
>
> } while (remainingToExtract > 0);
>
> return result;
> }
>
> ---------- Forwarded message ----------
> From: PyungMoon Oh <qud...@gm...>
> Date: 2008. 1. 18 17:31
> Subject: i got an error with xSocket V1_2_1
> To: xso...@li...
>
> i got an error message like this..
> but i think it can not be happen if there is no another thread which is
> accessing the buffer..
> as i know "public LinkedList<ByteBuffer> extract(LinkedList<ByteBuffer>
> inOutBuffer, int length) throws IOException, BufferUnderflowException {"
> method check limit before call " java.nio.Buffer.limit" method..
> am i right??
>
> but i can not find it..
>
> can someone tell me why it's happening?? and which threads are accessing
> the buffer?
>
> java.lang.IllegalArgumentException
> at java.nio.Buffer.limit(Buffer.java:249)
> at org.xsocket.stream.ByteBufferParser.extract(
> ByteBufferParser.java:167)
> at org.xsocket.stream.Connection.extractBytesByLength(
> Connection.java:915)
> at org.xsocket.stream.NonBlockingConnection.readByteBufferByLength
> (NonBlockingConnection.java:574)
> at org.xsocket.stream.NonBlockingConnection.readBytesByLength(
> NonBlockingConnection.java:609)
>
>
> thanks//
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> xSocket-develop mailing list
> xSo...@li...
> https://lists.sourceforge.net/lists/listinfo/xsocket-develop
>
>
|