activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r541363 - /activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
Date Thu, 24 May 2007 17:26:10 GMT
Author: tabish
Date: Thu May 24 10:26:09 2007
New Revision: 541363

URL: http://svn.apache.org/viewvc?view=rev&rev=541363
Log:
https://issues.apache.org/activemq/browse/AMQCPP-117

Modified:
    activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp

Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp?view=diff&rev=541363&r1=541362&r2=541363
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
Thu May 24 10:26:09 2007
@@ -23,7 +23,7 @@
 using namespace activemq::connector::openwire::commands;
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQBytesMessage::ActiveMQBytesMessage() : 
+ActiveMQBytesMessage::ActiveMQBytesMessage() :
     ActiveMQMessageBase< cms::BytesMessage >(),
     dataInputStream( &inputStream ),
     dataOutputStream( &outputStream )
@@ -43,12 +43,12 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQBytesMessage::setBodyBytes( const unsigned char* buffer, 
-                                         std::size_t numBytes ) 
+void ActiveMQBytesMessage::setBodyBytes( const unsigned char* buffer,
+                                         std::size_t numBytes )
     throw( cms::CMSException ) {
 
     try{
-        
+
         clearBody();
         for( size_t i = 0; i < numBytes; ++i ) {
             getContent().push_back( buffer[i] );
@@ -62,7 +62,12 @@
 const unsigned char* ActiveMQBytesMessage::getBodyBytes(void) const {
 
     try{
-        return reinterpret_cast<const unsigned char*>( &( getContent()[0] ) );
+
+        if( getContent().size() > 0 ) {
+            return reinterpret_cast<const unsigned char*>( &( getContent()[0] )
);
+        } else {
+            return NULL;
+        }
     }
     AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
     AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
@@ -83,7 +88,7 @@
 
     try{
         readOnly = true;
-        inputStream.setBuffer( getContent() );            
+        inputStream.setBuffer( getContent() );
     }
     AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
     AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
@@ -134,7 +139,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t ActiveMQBytesMessage::readBytes( std::vector<unsigned char>& value
) 
+std::size_t ActiveMQBytesMessage::readBytes( std::vector<unsigned char>& value
)
     throw ( cms::CMSException ) {
 
     try{
@@ -157,7 +162,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t ActiveMQBytesMessage::readBytes( unsigned char*& buffer, std::size_t length
) 
+std::size_t ActiveMQBytesMessage::readBytes( unsigned char*& buffer, std::size_t length
)
     throw ( cms::CMSException ) {
 
     try{
@@ -180,7 +185,7 @@
     AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
     AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
 }
-                         
+
 ////////////////////////////////////////////////////////////////////////////////
 char ActiveMQBytesMessage::readChar() throw ( cms::CMSException ) {
 



Mime
View raw message