You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2018/08/25 20:29:25 UTC

svn commit: r1839104 - in /jmeter/trunk: src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java xdocs/changes.xml

Author: pmouawad
Date: Sat Aug 25 20:29:25 2018
New Revision: 1839104

URL: http://svn.apache.org/viewvc?rev=1839104&view=rev
Log:
Bug 62616 - FTPSampler: Upload file-size is not counted in sentBytes
Bugzilla Id: 62616

Modified:
    jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java?rev=1839104&r1=1839103&r2=1839104&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java (original)
+++ jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java Sat Aug 25 20:29:25 2018
@@ -36,6 +36,7 @@ import java.util.Set;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.NullOutputStream;
 import org.apache.commons.io.output.TeeOutputStream;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.net.ftp.FTP;
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPReply;
@@ -89,6 +90,7 @@ public class FTPSampler extends Abstract
     private transient volatile FTPClient savedClient; // used for interrupting the sampler
 
     public FTPSampler() {
+        super();
     }
 
     public String getUsername() {
@@ -208,10 +210,10 @@ public class FTPSampler extends Abstract
                         if (contents.length() > 0){
                             byte[] bytes = contents.getBytes(); // TODO - charset?
                             input = new ByteArrayInputStream(bytes);
-                            res.setBytes((long)bytes.length);
+                            res.setSentBytes((long)bytes.length);
                         } else {
                             File infile = new File(local);
-                            res.setBytes(infile.length());
+                            res.setSentBytes(infile.length());
                             fileIS = new FileInputStream(infile); // NOSONAR False positive, fileIS is closed in finally and not overwritten
                             input = new BufferedInputStream(fileIS);
                         }
@@ -269,12 +271,17 @@ public class FTPSampler extends Abstract
                     res.setResponseMessage(ftp.getReplyString());
                 }
             } else {
-                res.setResponseCode("501"); // TODO
-                res.setResponseMessage("Could not connect");
-                res.setResponseMessage(ftp.getReplyString());
+                res.setResponseCode("501");
+                String replyString = ftp.getReplyString();
+                if(StringUtils.isEmpty(replyString)) {
+                    res.setResponseMessage("Could not connect");
+                }
+                else {
+                    res.setResponseMessage(replyString);
+                }
             }
         } catch (IOException ex) {
-            res.setResponseCode("000"); // TODO
+            res.setResponseCode("000");
             res.setResponseMessage(ex.toString());
         } finally {
             savedClient = null;
@@ -282,10 +289,12 @@ public class FTPSampler extends Abstract
                 try {
                     ftp.logout();
                 } catch (IOException ignored) {
+                    // NOOP
                 }
                 try {
                     ftp.disconnect();
                 } catch (IOException ignored) {
+                    // NOOP
                 }
             }
             IOUtils.closeQuietly(input);
@@ -312,10 +321,12 @@ public class FTPSampler extends Abstract
             try {
                 client.abort();
             } catch (IOException ignored) {
+                // NOOP
             }
             try {
                 client.disconnect();
             } catch (IOException ignored) {
+             // NOOP
             }
         }
         return client != null;

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1839104&r1=1839103&r2=1839104&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sat Aug 25 20:29:25 2018
@@ -208,6 +208,7 @@ this behaviour, set <code>httpclient.res
     <li><bug>58807</bug><code>https.use.cached.ssl.context=false</code> is broken</li>
     <li><bug>62235</bug>Java 9 - illegal reflective access by org.apache.jmeter.util.HostNameSetter</li>
     <li><bug>62464</bug>Set start- and end-time on JMS publisher sampler, even if initialization fails.</li>
+    <li><bug>62616</bug>FTPSampler: Upload file-size is not counted in sentBytes</li>
 </ul>
 
 <h3>Controllers</h3>