diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2009-12-17 17:22:41 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2009-12-17 17:22:41 +0000 |
commit | 0396c217e8f507b24136f5d7dce588d617481fe7 (patch) | |
tree | 1f992737b484b5b9dccb03f835266689de471030 | |
parent | e4a121846bdabda5b7d1edc2ebf33f453ee61ede (diff) | |
download | qpid-python-0396c217e8f507b24136f5d7dce588d617481fe7.tar.gz |
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.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@891805 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java | 13 | ||||
-rw-r--r-- | qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java | 7 |
2 files changed, 16 insertions, 4 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java index 234212c301..535b55ced5 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java @@ -85,11 +85,18 @@ public abstract class AbstractBytesMessage extends AbstractJMSMessage } 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) { diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java index c220694b50..9f1c0ca9eb 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java @@ -57,12 +57,17 @@ public class Functions 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 != '\\') { |