jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1835661 - /jmeter/trunk/src/core/org/apache/jmeter/report/core/Sample.java
Date Wed, 11 Jul 2018 18:44:29 GMT
Author: fschumacher
Date: Wed Jul 11 18:44:29 2018
New Revision: 1835661

URL: http://svn.apache.org/viewvc?rev=1835661&view=rev
Log:
Check for metadata before getting a value for the sampler.

Followup to r1835351. The eager evaluating led to test failures.
It would probably better to store a zero as Integer and Long instead of
calling Long#valueOf(0L) each time we need a zero.

Bugzilla Id: 62426

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

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/core/Sample.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/core/Sample.java?rev=1835661&r1=1835660&r2=1835661&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/core/Sample.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/core/Sample.java Wed Jul 11 18:44:29 2018
@@ -67,14 +67,21 @@ public class Sample {
         this.metadata = metadata;
         this.data = data;
         this.storesStartTimeStamp = JMeterUtils.getPropDefault("sampleresult.timestamp.start",
false);
-        this.elapsedTime = getData(long.class, CSVSaveService.CSV_ELAPSED).longValue();
-        this.timestamp = getData(long.class, CSVSaveService.TIME_STAMP).longValue();
-        this.latency = getData(long.class, CSVSaveService.CSV_LATENCY).longValue();
-        this.connectTime = metadata.indexOf(CSVSaveService.CSV_CONNECT_TIME) >= 0 ? getData(long.class,
CSVSaveService.CSV_CONNECT_TIME).longValue() : 0L;
-        this.success = getData(boolean.class, CSVSaveService.SUCCESSFUL).booleanValue();
-        this.receivedBytes = getData(long.class, CSVSaveService.CSV_BYTES).longValue();
-        this.sentBytes = metadata.indexOf(CSVSaveService.CSV_SENT_BYTES) >= 0 ? getData(long.class,
CSVSaveService.CSV_SENT_BYTES).longValue() : 0L;
-        this.groupThreads = getData(int.class, CSVSaveService.CSV_THREAD_COUNT1).intValue();
+        this.elapsedTime = getPossibleValue(metadata, CSVSaveService.CSV_ELAPSED, long.class,
Long.valueOf(0L)).longValue();
+        this.timestamp = getPossibleValue(metadata, CSVSaveService.TIME_STAMP, long.class,
Long.valueOf(0L)).longValue();
+        this.latency = getPossibleValue(metadata, CSVSaveService.CSV_LATENCY, long.class,
Long.valueOf(0L)).longValue();
+        this.connectTime = getPossibleValue(metadata, CSVSaveService.CSV_CONNECT_TIME, long.class,
Long.valueOf(0L)).longValue();
+        this.success = getPossibleValue(metadata, CSVSaveService.SUCCESSFUL, boolean.class,
Boolean.TRUE).booleanValue();
+        this.receivedBytes = getPossibleValue(metadata, CSVSaveService.CSV_BYTES, long.class,
Long.valueOf(0L)).longValue();
+        this.sentBytes = getPossibleValue(metadata, CSVSaveService.CSV_SENT_BYTES, long.class,
Long.valueOf(0L)).longValue();
+        this.groupThreads = getPossibleValue(metadata, CSVSaveService.CSV_THREAD_COUNT1,
int.class, Integer.valueOf(0)).intValue();
+    }
+
+    private <T> T getPossibleValue(SampleMetadata metadata, String key, Class<T>
type, T defaultValue) {
+        if (metadata.indexOf(key) >= 0) {
+            return (T) getData(type, key);
+        }
+        return defaultValue;
     }
 
     /**



Mime
View raw message