jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1719793 - in /jmeter/trunk/src/core/org/apache/jmeter/report/core: AbstractSampleWriter.java CsvSampleWriter.java
Date Sun, 13 Dec 2015 11:22:40 GMT
Author: fschumacher
Date: Sun Dec 13 11:22:40 2015
New Revision: 1719793

URL: http://svn.apache.org/viewvc?rev=1719793&view=rev
Log:
Check for not-null first, instead of waiting for the npe to happen. After
that, there is no need to catch a npe just to throw it again.

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/report/core/AbstractSampleWriter.java
    jmeter/trunk/src/core/org/apache/jmeter/report/core/CsvSampleWriter.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/core/AbstractSampleWriter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/core/AbstractSampleWriter.java?rev=1719793&r1=1719792&r2=1719793&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/core/AbstractSampleWriter.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/core/AbstractSampleWriter.java Sun Dec
13 11:22:40 2015
@@ -26,6 +26,7 @@ import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 
+import org.apache.commons.lang3.Validate;
 import org.apache.jorphan.util.JOrphanUtils;
 
 /**

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/core/CsvSampleWriter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/core/CsvSampleWriter.java?rev=1719793&r1=1719792&r2=1719793&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/core/CsvSampleWriter.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/core/CsvSampleWriter.java Sun Dec 13 11:22:40
2015
@@ -114,29 +114,27 @@ public class CsvSampleWriter extends Abs
 
     @Override
     public long write(Sample sample) {
-        try {
-            row.setLength(0);
-            char[] specials = new char[] { separator,
-                    CSVSaveService.QUOTING_CHAR, CharUtils.CR, CharUtils.LF };
-            for (int i = 0; i < columnCount; i++) {
-                String data = sample.getString(i);
-                row.append(CSVSaveService.quoteDelimiters(data, specials))
-                        .append(separator);
-            }
-            int rowLength = row.length() - 1;
-            row.setLength(rowLength);
-            writer.println(row.toString());
-            sampleCount++;
-        } catch (NullPointerException npe) {
-            if (writer == null) {
-                throw new IllegalStateException(
-                        "No writer set ! Call setWriter() first !", npe);
-            } else if (sample == null) {
-                throw new ArgumentNullException("sample");
-            } else {
-                throw npe;
-            }
+        if (sample == null) {
+            throw new ArgumentNullException("sample");
         }
+        if (writer == null) {
+            throw new IllegalStateException(
+                    "No writer set! Call setWriter() first!");
+        }
+
+        row.setLength(0);
+        char[] specials = new char[] { separator,
+                CSVSaveService.QUOTING_CHAR, CharUtils.CR, CharUtils.LF };
+        for (int i = 0; i < columnCount; i++) {
+            String data = sample.getString(i);
+            row.append(CSVSaveService.quoteDelimiters(data, specials))
+                    .append(separator);
+        }
+        int rowLength = row.length() - 1;
+        row.setLength(rowLength);
+        writer.println(row.toString());
+        sampleCount++;
+
         return sampleCount;
     }
 



Mime
View raw message