activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r599108 - /activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ByteBuffer.cpp
Date Wed, 28 Nov 2007 19:32:25 GMT
Author: tabish
Date: Wed Nov 28 11:32:25 2007
New Revision: 599108

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

Working on the NIO package

Modified:
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ByteBuffer.cpp

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ByteBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ByteBuffer.cpp?rev=599108&r1=599107&r2=599108&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ByteBuffer.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/nio/ByteBuffer.cpp Wed Nov 28 11:32:25
2007
@@ -303,11 +303,11 @@
 
         return *this;
     }
-    DECAF_CATCH_RETHROW( BufferUnderflowException )
+    DECAF_CATCH_RETHROW( BufferOverflowException )
     DECAF_CATCH_RETHROW( ReadOnlyBufferException )
-    DECAF_CATCH_RETHROW( NullPointerException )
-    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
-    DECAF_CATCHALL_THROW( BufferUnderflowException )
+    DECAF_CATCH_RETHROW( IllegalArgumentException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferOverflowException )
+    DECAF_CATCHALL_THROW( BufferOverflowException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -328,18 +328,18 @@
                 "ByteBuffer::put - This buffer is Read Only.");
         }
 
-        if( length > this->remaining() ) {
-            throw BufferOverflowException(
-                __FILE__, __LINE__,
-                "ByteBuffer::put - Not Enough space to store requested Data.");
-        }
-
         if( buffer == NULL ) {
             throw NullPointerException(
                 __FILE__, __LINE__,
                 "ByteBuffer::put - Passed Buffer is Null.");
         }
 
+        if( length > this->remaining() ) {
+            throw BufferOverflowException(
+                __FILE__, __LINE__,
+                "ByteBuffer::put - Not Enough space to store requested Data.");
+        }
+
         // read length bytes starting from the offset
         for( std::size_t ix = 0; ix < length; ++ix ) {
             this->put( buffer[ix + offset] );
@@ -347,11 +347,11 @@
 
         return *this;
     }
-    DECAF_CATCH_RETHROW( BufferUnderflowException )
+    DECAF_CATCH_RETHROW( BufferOverflowException )
     DECAF_CATCH_RETHROW( ReadOnlyBufferException )
     DECAF_CATCH_RETHROW( NullPointerException )
-    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
-    DECAF_CATCHALL_THROW( BufferUnderflowException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferOverflowException )
+    DECAF_CATCHALL_THROW( BufferOverflowException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -364,14 +364,14 @@
             return *this;
         }
 
-        this->get( &buffer[0], 0, buffer.size() );
+        this->put( &buffer[0], 0, buffer.size() );
 
         return *this;
     }
-    DECAF_CATCH_RETHROW( BufferUnderflowException )
+    DECAF_CATCH_RETHROW( BufferOverflowException )
     DECAF_CATCH_RETHROW( ReadOnlyBufferException )
-    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
-    DECAF_CATCHALL_THROW( BufferUnderflowException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferOverflowException )
+    DECAF_CATCHALL_THROW( BufferOverflowException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -734,6 +734,12 @@
             throw ReadOnlyBufferException(
                 __FILE__, __LINE__,
                 "ByteBuffer::put() - Buffer is Read Only." );
+        }
+
+        if( (offset + index) >= this->limit() ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__,
+                "ByteBuffer::get - Not enough data to fill request." );
         }
 
         (*(this->_array))[this->offset + index] = value;



Mime
View raw message