qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject svn commit: r1069472 - in /qpid/branches/0.5.x-dev/qpid/java: client/src/main/java/org/apache/qpid/client/message/ client/src/test/java/org/apache/qpid/test/unit/message/ common/src/main/java/org/apache/qpid/transport/util/
Date Thu, 10 Feb 2011 17:12:14 GMT
Author: grkvlt
Date: Thu Feb 10 17:12:13 2011
New Revision: 1069472

URL: http://svn.apache.org/viewvc?rev=1069472&view=rev
Log:
QPID-1830: backport fix from trunk

Modified:
    qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
    qpid/branches/0.5.x-dev/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java
    qpid/branches/0.5.x-dev/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java

Modified: qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java?rev=1069472&r1=1069471&r2=1069472&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
Thu Feb 10 17:12:13 2011
@@ -86,10 +86,13 @@ public abstract class AbstractBytesMessa
 
     public String toBodyString() throws JMSException
     {  
-        checkReadable();
         try
         {
-            return Functions.str(_data.buf(), 100);
+            if (_data == null)
+            {
+                return "";
+            }
+            return Functions.str(_data.buf(), 100, 0);
         }
         catch (Exception e)
         {

Modified: qpid/branches/0.5.x-dev/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java?rev=1069472&r1=1069471&r2=1069472&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/client/src/test/java/org/apache/qpid/test/unit/message/MessageConverterTest.java
Thu Feb 10 17:12:13 2011
@@ -76,6 +76,18 @@ public class MessageConverterTest extend
         assertEquals("Converted message text mismatch", ((JMSTextMessage) newMessage).getText(),
testTextMessage.getText());
     }
 
+    /**
+     * Test for QPID-1830 issue in {@link AbstractBytesMessage#toBodyString()}.
+     * 
+     * @throws Exception if test failes
+     */
+    public void testBytesMessageToBodyString() throws Exception
+    {
+        BytesMessage newMessage =  _session.createBytesMessage();
+        newMessage.writeBytes(new byte[] { 0x00, 0x10, 0x20, 0x40 });
+        newMessage.toString();
+    }
+
     public void testJMSMapMessageConversion() throws Exception
     {
         AbstractJMSMessage newMessage = new MessageConverter(_session, (MapMessage) testMapMessage).getConvertedMessage();

Modified: qpid/branches/0.5.x-dev/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java?rev=1069472&r1=1069471&r2=1069472&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/common/src/main/java/org/apache/qpid/transport/util/Functions.java
Thu Feb 10 17:12:13 2011
@@ -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++)
+        for (int i = start; i < min(buf.limit(), limit); i++)
         {
-            byte c = buf.get(buf.position() + i);
+            byte c = buf.get(i);
 
             if (c > 31 && c < 127 && c != '\\')
             {



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message