activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r559896 - /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp
Date Thu, 26 Jul 2007 17:33:17 GMT
Author: tabish
Date: Thu Jul 26 10:33:16 2007
New Revision: 559896

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

Attempting to fix the code so that we meet the Contract of InputStream

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp?view=diff&rev=559896&r1=559895&r2=559896
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/ByteArrayInputStream.cpp Thu Jul
26 10:33:16 2007
@@ -96,12 +96,16 @@
                                    throw ( IOException ){
     std::size_t ix = 0;
 
-    if( (std::size_t)distance( pos, activeBuffer->end() ) < bufferSize ) {
-        // We don't have enough data to fulfill the request.
-        throw IOException(
-            __FILE__, __LINE__,
-            "Reached the end of the buffer" );
+    if( pos == activeBuffer->end() ) {
+        return -1;
     }
+
+    // How far are we from end
+    std::size_t remaining = (std::size_t)distance( pos, activeBuffer->end() );
+
+    // We only read as much as is left if the amount remaining is less than
+    // the amount of data asked for.
+    bufferSize = remaining < bufferSize ? remaining : bufferSize;
 
     for( ; ix < bufferSize; ++ix, ++pos) {
         buffer[ix] = *(pos);



Mime
View raw message