qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Ritchie (JIRA)" <qpid-...@incubator.apache.org>
Subject [jira] Created: (QPID-1092) JMSObjectMessage.toBodyString corrupts the ByteBuffer if the data is not a String
Date Mon, 26 May 2008 13:33:56 GMT
JMSObjectMessage.toBodyString corrupts the ByteBuffer if the data is not a String
---------------------------------------------------------------------------------

                 Key: QPID-1092
                 URL: https://issues.apache.org/jira/browse/QPID-1092
             Project: Qpid
          Issue Type: Bug
          Components: Java Client
    Affects Versions: M2.1, M2
            Reporter: Martin Ritchie
             Fix For: M3


Summary:

The JMSObjectMessage toBodyString calls toString(ByteBuffer b). This method assumes that the
Object Message can be converted to a string using:
            return data.getString(Charset.forName("UTF8").newDecoder());
However, if this fails then the byte buffer limit value is set to the last byte read by the
decoder.

Subsequent calls to getObject() will result in an EOFException as the full buffer is unable
to be read due to the limit point change.


Steps to Reproduce:
Send a java object and print the message S.o.pln(message); before you call getObject().

Defect Identification:
The current position in the buffer is recorded but the limit is not. Recording and resetting
the limit would be one possible approach.

Proposed Changes:
Remove the toString(ByteBuffer b) method and change the toBodyString to perform:

String.valueOf(getObject());

This will ensure that the toString will work as long as getObject() can be continually called.

Test Strategy:
To test we should create an additional test in ObjectMessageTest

testToString()

//Setup
//Receive Message
ObjectMessage message=client.receive();

//Test
String messageAsString = message.toString();

Object objectAfterToString = message.getObject();
// catch and fail all errors
AssertNotNull("Error Object not received after toString",objectAfterToString );

//Perform the toBodyString Explicitly
String messageBodyAsString = message.toBodyString();

Object objectAfterToBodyString = message.getObject();
// catch and fail all errors
AssertNotNull("Error Object not received after toBodyString",objectAfterToBodyString );


Change Review/Sign-off:
Sign off given to proceed with changes

External Subversion Commit:
Details of commit location. URL and revision number

Code Review/Sign-off:
Sign off given to proceed with changes

Included in RC:
Specify the RC this JIRA is included in.

Released/Closed:
Ensure when closing as included in a release the Fix-For is correct
OR de-scope to Unprioritised.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message