jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1573179 - /jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
Date Sat, 01 Mar 2014 14:12:51 GMT
Author: sebb
Date: Sat Mar  1 14:12:50 2014
New Revision: 1573179

URL: http://svn.apache.org/r1573179
Log:
Add extra debug

Modified:
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java?rev=1573179&r1=1573178&r2=1573179&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
(original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPClientImpl.java
Sat Mar  1 14:12:50 2014
@@ -47,8 +47,8 @@ import org.apache.log.Logger;
 public class TCPClientImpl extends AbstractTCPClient {
     private static final Logger log = LoggingManager.getLoggerForClass();
 
-    private int eolInt = JMeterUtils.getPropDefault("tcp.eolByte", 1000); // $NON-NLS-1$
-    private String charset = JMeterUtils.getPropDefault("tcp.charset", Charset.defaultCharset().name());
// $NON-NLS-1$
+    private static final int eolInt = JMeterUtils.getPropDefault("tcp.eolByte", 1000); //
$NON-NLS-1$
+    private static final String charset = JMeterUtils.getPropDefault("tcp.charset", Charset.defaultCharset().name());
// $NON-NLS-1$
     // default is not in range of a byte
 
     public TCPClientImpl() {
@@ -71,11 +71,11 @@ public class TCPClientImpl extends Abstr
      */
     @Override
     public void write(OutputStream os, String s)  throws IOException{
-        os.write(s.getBytes(charset)); 
-        os.flush();
         if(log.isDebugEnabled()) {
-            log.debug("Wrote: " + s);
+            log.debug("WriteS: " + showEOL(s));
         }
+        os.write(s.getBytes(charset)); 
+        os.flush();
     }
 
     /**
@@ -85,6 +85,9 @@ public class TCPClientImpl extends Abstr
     public void write(OutputStream os, InputStream is) throws IOException{
         byte buff[]=new byte[512];
         while(is.read(buff) > 0){
+            if(log.isDebugEnabled()) {
+                log.debug("WriteIS: " + showEOL(new String(buff, charset)));
+            }
             os.write(buff);
             os.flush();
         }
@@ -114,7 +117,22 @@ public class TCPClientImpl extends Abstr
             }
             return w.toString(charset);
         } catch (IOException e) {
-            throw new ReadException("", e, w.toString());
+            throw new ReadException("Error reading from server, bytes read: " + w.size(),
e, w.toString());
+        }
+    }
+
+    private String showEOL(final String input) {
+        StringBuilder sb = new StringBuilder(input.length()*2);
+        for(int i=0; i < input.length(); i++) {
+            char ch = input.charAt(i);
+            if (ch < ' ') {
+                sb.append('[');
+                sb.append((int)ch);
+                sb.append(']');
+            } else {
+                sb.append(ch);
+            }
         }
+        return sb.toString();
     }
 }



Mime
View raw message