I've had a look at the rest code and I would suggest the checkWritable();
is not required. Removing this as below would prevent the exception from
occurring.
The problem is I don't understand the difference in mina between flip()
and rewind().
from the mina spec.
flip() makes a buffer ready for a new sequence of channel-write or
relative get operations: It sets the limit to the current position and
then sets the position to zero.
rewind() makes a buffer ready for re-reading the data that it already
contains: It leaves the limit unchanged and sets the position to zero.
I seems to me that rewind() would be what we want for a JMS reset() [Puts
the message body in read-only mode and repositions the stream of bytes to
the beginning. ]
However the BytesMessageTest fails when using rewind() as the size of the
read bytes is not known. Which suggests that the code uses the limit value
in the mina buffer to determine the size of the ByteMessage and as it
isn't set with a rewind() it returns the size of the Mina buffer (1024).
I'm sure flip() is correct and all that need be done is remove the
checkWritable() call. It would be good if someone (I guess Robert or
Gordon) more familiar with this bit of code could OK this change.
public void reset() throws JMSException
{
//checkWritable();
_data.flip();
_readable = true;
}
Cheers
--
Martin
"Colin Crist" <[EMAIL PROTECTED]>
2006-09-05 17:36
Please respond to qpid-dev
To: <[email protected]>
cc:
Subject: Bug: BytesMessage.reset() throws
MessageNotWriteableException
Hi,
BytesMessage.reset() can be called on a read only message, its purpose
is to "reset" the message so it can be read again from the start, it
does not affect the message content.
2006-09-05 17:25:34,436 [AWT-EventQueue-0] ERROR
hermes.renderers.HexMessageRenderer - exception converting message to
byte[]:
javax.jms.MessageNotWriteableException: You need to call clearBody() to
make the message writable
at
org.apache.qpid.client.message.JMSBytesMessage.checkWritable(JMSBytesMes
sage.java:148)
at
org.apache.qpid.client.message.JMSBytesMessage.reset(JMSBytesMessage.jav
a:342)
Regards,
Colin
http://hermesjms.com
This communication is for informational purposes only. It is not intended as an
offer or solicitation for the purchase or sale of any financial instrument or
as an official confirmation of any transaction. All market prices, data and
other information are not warranted as to completeness or accuracy and are
subject to change without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and
affiliates.
This transmission may contain information that is privileged, confidential,
legally privileged, and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any disclosure,
copying, distribution, or use of the information contained herein (including
any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and
any attachments are believed to be free of any virus or other defect that might
affect any computer system into which it is received and opened, it is the
responsibility of the recipient to ensure that it is virus free and no
responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and
affiliates, as applicable, for any loss or damage arising in any way from its
use. If you received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.