Author: sebb
Date: Tue Oct 25 17:51:50 2011
New Revision: 1188830

URL: http://svn.apache.org/viewvc?rev=1188830&view=rev
Log:
Bug 52072 - LengthPrefixedBinaryTcpClientImpl may end a sample prematurely

Modified:
    jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java
    
jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImpl.java
    jakarta/jmeter/trunk/xdocs/changes.xml

Modified: 
jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java?rev=1188830&r1=1188829&r2=1188830&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java 
(original)
+++ jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java 
Tue Oct 25 17:51:50 2011
@@ -490,4 +490,28 @@ public final class JOrphanUtils {
         if (in < 10) return (byte) (in+'0');
         return (byte) ((in-10)+'a');
     }
+
+    /**
+     * Read as much as possible into buffer.
+     * 
+     * @param is the stream to read from
+     * @param buffer output buffer
+     * @param offset offset into buffer
+     * @param length number of bytes to read
+     * 
+     * @return the number of bytes actually read
+     * @throws IOException 
+     */
+    public static int read(InputStream is, byte[] buffer, int offset, int 
length) throws IOException {
+        int remaining = length;
+        while ( remaining > 0 ) {
+            int location = ( length - remaining );
+            int count = is.read( buffer, location, remaining );
+            if ( -1 == count ) { // EOF
+                break;
+            }
+            remaining -= count;
+        }
+        return length - remaining;
+    }
 }

Modified: 
jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImpl.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImpl.java?rev=1188830&r1=1188829&r2=1188830&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImpl.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/LengthPrefixedBinaryTCPClientImpl.java
 Tue Oct 25 17:51:50 2011
@@ -86,8 +86,8 @@ public class LengthPrefixedBinaryTCPClie
             if (is.read(lengthBuffer, 0, lengthPrefixLen) == lengthPrefixLen) {
                 msgLen = byteArrayToInt(lengthBuffer);
                 msg = new byte[msgLen];
-                int bytes = is.read(msg);
-                if (bytes < msgLen){
+                int bytes = JOrphanUtils.read(is, msg, 0, msgLen);
+                if (bytes < msgLen) {
                     log.warn("Incomplete message read, expected: "+msgLen+" 
got: "+bytes);
                 }
             }

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1188830&r1=1188829&r2=1188830&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Tue Oct 25 17:51:50 2011
@@ -102,6 +102,7 @@ Mirror server now uses default port 8081
 <li>Bug 51691 - Authorization does not work for JMS Publisher and JMS 
Subscriber</li>
 <li>Bug 52036 - Durable Subscription fails with ActiveMQ due to missing 
clientId field</li>
 <li>Bug 52044 - JMS Subscriber used with many threads leads to 
javax.naming.NamingException: Something already bound with ActiveMQ</li>
+<li>Bug 52072 - LengthPrefixedBinaryTcpClientImpl may end a sample 
prematurely</li>
 </ul>
 
 <h3>Controllers</h3>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to