You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/10/19 19:56:07 UTC

svn commit: r586560 - in /activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire: marshal/PrimitiveMapMarshaller.cpp marshal/PrimitiveMapMarshaller.h utils/OpenwireStringSupport.cpp

Author: tabish
Date: Fri Oct 19 10:56:07 2007
New Revision: 586560

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

Working on fixing empty string and null string in properties crashes the client.  

Modified:
    activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp
    activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h
    activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/OpenwireStringSupport.cpp

Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp?rev=586560&r1=586559&r2=586560&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp Fri Oct 19 10:56:07 2007
@@ -42,12 +42,9 @@
         ByteArrayOutputStream bytesOut( dest );
         DataOutputStream dataOut( &bytesOut );
 
-        if( map == NULL )
-        {
+        if( map == NULL ) {
             dataOut.writeInt( -1 );
-        }
-        else
-        {
+        } else {
             dataOut.writeInt( (int)map->size() );
 
             std::vector<std::string> keys = map->getKeys();
@@ -77,12 +74,10 @@
 
         int size = dataIn.readInt();
 
-        if( size > 0 )
-        {
+        if( size > 0 ) {
             PrimitiveMap* map = new PrimitiveMap;
 
-            for( int i=0; i < size; i++ )
-            {
+            for( int i=0; i < size; i++ ) {
                 std::string key = OpenwireStringSupport::readString( dataIn );
                 unmarshalPrimitive( dataIn, key, *map );
             }
@@ -91,8 +86,8 @@
         }
 
         return NULL;
-
     }
+    AMQ_CATCH_EXCEPTION_CONVERT( io::IOException, ActiveMQException )
     AMQ_CATCH_RETHROW( ActiveMQException )
     AMQ_CATCHALL_THROW( ActiveMQException )
 }
@@ -116,15 +111,14 @@
 
         int size = dataIn.readInt();
 
-        if( size > 0 )
-        {
-            for( int i=0; i < size; i++ )
-            {
+        if( size > 0 ) {
+            for( int i=0; i < size; i++ ) {
                 std::string key = OpenwireStringSupport::readString( dataIn );
                 unmarshalPrimitive( dataIn, key, *map );
             }
         }
     }
+    AMQ_CATCH_EXCEPTION_CONVERT( io::IOException, ActiveMQException )
     AMQ_CATCH_RETHROW( ActiveMQException )
     AMQ_CATCHALL_THROW( ActiveMQException )
 }
@@ -132,7 +126,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 void PrimitiveMapMarshaller::marshalPrimitive( io::DataOutputStream& dataOut,
                                                util::PrimitiveMap::ValueNode& value )
-                                                    throw ( cms::CMSException ) {
+                                                    throw ( io::IOException ) {
 
     try {
 
@@ -198,16 +192,6 @@
 
             OpenwireStringSupport::writeString( dataOut, &data );
         }
-//        else if( value is IDictionary )
-//        {
-//            dataOut.Write( MAP_TYPE );
-//            MarshalPrimitiveMap((IDictionary) value, dataOut);
-//        }
-//        else if( value is IList )
-//        {
-//            dataOut.Write( LIST_TYPE );
-//            MarshalPrimitiveList((IList) value, dataOut);
-//        }
         else
         {
             throw IOException(
@@ -216,15 +200,16 @@
                 "Object is not a primitive: ");
         }
     }
-    AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
+    AMQ_CATCH_RETHROW( io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, io::IOException )
+    AMQ_CATCHALL_THROW( io::IOException )
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 void PrimitiveMapMarshaller::unmarshalPrimitive( io::DataInputStream& dataIn,
                                                  const std::string& key,
                                                  util::PrimitiveMap& map )
-                                                    throw ( cms::CMSException ) {
+                                                    throw ( io::IOException ) {
 
     try {
 
@@ -271,12 +256,6 @@
                     key,
                     OpenwireStringSupport::readString( dataIn ) );
                 break;
-//            case PrimitiveMap::MAP_TYPE:
-//                value = UnmarshalPrimitiveMap(dataIn);
-//                break;
-//            case PrimitiveMap::LIST_TYPE:
-//                value = UnmarshalPrimitiveList(dataIn);
-//                break;
             default:
                 throw IOException(
                     __FILE__,
@@ -285,30 +264,7 @@
                     "Unsupported data type: ");
         }
     }
-    AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
+    AMQ_CATCH_RETHROW( io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, io::IOException )
+    AMQ_CATCHALL_THROW( io::IOException )
 }
-
-/*
-
-        public static void MarshalPrimitiveList(IList list, BinaryWriter dataOut)
-        {
-            dataOut.Write((int) list.Count);
-            foreach (Object element in list)
-            {
-                MarshalPrimitive(dataOut, element);
-            }
-        }
-
-        public static IList UnmarshalPrimitiveList(BinaryReader dataIn)
-        {
-            int size = dataIn.ReadInt32();
-            IList answer = new ArrayList(size);
-            while (size-- > 0) {
-                answer.Add(UnmarshalPrimitive(dataIn));
-            }
-            return answer;
-        }
-
-
-*/

Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h?rev=586560&r1=586559&r2=586560&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h Fri Oct 19 10:56:07 2007
@@ -21,6 +21,7 @@
 #include <activemq/util/PrimitiveMap.h>
 #include <activemq/io/DataOutputStream.h>
 #include <activemq/io/DataInputStream.h>
+#include <activemq/io/IOException.h>
 
 namespace activemq{
 namespace connector{
@@ -77,7 +78,7 @@
          */
         static void marshalPrimitive( io::DataOutputStream& dataOut,
                                       util::PrimitiveMap::ValueNode& value )
-                                        throw ( cms::CMSException );
+                                        throw ( io::IOException );
 
         /**
          * Unmarshals a Primitive Type from the stream, and returns it as a
@@ -90,7 +91,7 @@
         static void unmarshalPrimitive( io::DataInputStream& dataIn,
                                         const std::string& key,
                                         util::PrimitiveMap& map )
-                                            throw ( cms::CMSException );
+                                            throw ( io::IOException );
 
     };
 

Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/OpenwireStringSupport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/OpenwireStringSupport.cpp?rev=586560&r1=586559&r2=586560&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/OpenwireStringSupport.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/OpenwireStringSupport.cpp Fri Oct 19 10:56:07 2007
@@ -60,38 +60,10 @@
                     case 7:
                         /* 0xxxxxxx */
                         count++;
-//                        str.Append((char) c);
                         break;
                     case 12:
                     case 13:
-//                        /* 110x xxxx 10xx xxxx */
-//                        count += 2;
-//                        if (count > utflen)
-//                        {
-//                            throw CreateDataFormatException();
-//                        }
-//                        char2 = bytearr[count - 1];
-//                        if ((char2 & 0xC0) != 0x80)
-//                        {
-//                            throw CreateDataFormatException();
-//                        }
-//                        str.Append((char) (((c & 0x1F) << 6) | (char2 & 0x3F)));
-//                        break;
                     case 14:
-//                        /* 1110 xxxx 10xx xxxx 10xx xxxx */
-//                        count += 3;
-//                        if (count > utflen)
-//                        {
-//                            throw CreateDataFormatException();
-//                        }
-//                        char2 = bytearr[count - 2];
-//                        char3 = bytearr[count - 1];
-//                        if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
-//                        {
-//                            throw CreateDataFormatException();
-//                        }
-//                        str.Append((char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
-//                        break;
                     default :
                     {
                         /* 10xx xxxx, 1111 xxxx */
@@ -112,8 +84,9 @@
 
         return "";
     }
-    AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
+    AMQ_CATCH_RETHROW( io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, io::IOException )
+    AMQ_CATCHALL_THROW( io::IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -177,6 +150,7 @@
             dataOut.writeShort( (short)-1 );
         }
     }
-    AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
+    AMQ_CATCH_RETHROW( io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, io::IOException )
+    AMQ_CATCHALL_THROW( io::IOException )
 }