Author: rajith
Date: Thu Dec 17 17:22:41 2009
New Revision: 891805
URL: http://svn.apache.org/viewvc?rev=891805&view=rev
Log:
This is a fix for QPID-1830
I have removed the checkReadable() method from the toBodyString()
This will enable the toString() method to be used any time on message.
I have also modified the Functions.str() to take in an additional parameter to
denote to the starting position of the buffer.
Modified:
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
Modified:
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java?rev=891805&r1=891804&r2=891805&view=diff
==============================================================================
---
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
(original)
+++
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
Thu Dec 17 17:22:41 2009
@@ -85,11 +85,18 @@
}
public String toBodyString() throws JMSException
- {
- checkReadable();
+ {
try
{
- return Functions.str(_data.buf(), 100);
+ if (_data != null)
+ {
+ return Functions.str(_data.buf(), 100,0);
+ }
+ else
+ {
+ return "";
+ }
+
}
catch (Exception e)
{
Modified:
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java?rev=891805&r1=891804&r2=891805&view=diff
==============================================================================
---
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
(original)
+++
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
Thu Dec 17 17:22:41 2009
@@ -57,12 +57,17 @@
public static final String str(ByteBuffer buf, int limit)
{
+ return str(buf, limit,buf.position());
+ }
+
+ public static final String str(ByteBuffer buf, int limit,int start)
+ {
StringBuilder str = new StringBuilder();
str.append('"');
for (int i = 0; i < min(buf.remaining(), limit); i++)
{
- byte c = buf.get(buf.position() + i);
+ byte c = buf.get(start + i);
if (c > 31 && c < 127 && c != '\\')
{
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]