jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject [jmeter] branch master updated: Bug 64381 - PreciseThroughputTimer: On termination, log message contains negative value
Date Sun, 26 Apr 2020 16:09:03 GMT
This is an automated email from the ASF dual-hosted git repository.

pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 0772c1d  Bug 64381 - PreciseThroughputTimer: On termination, log message contains
negative value
0772c1d is described below

commit 0772c1d97e49aa6c5e615f1fc02ba7bd215c710b
Author: pmouawad <p.mouawad@ubik-ingenierie.com>
AuthorDate: Sun Apr 26 18:08:42 2020 +0200

    Bug 64381 - PreciseThroughputTimer: On termination, log message contains
    negative value
    
    Also avoid calling System.currentTimeMillis() too much times
---
 .../jmeter/timers/poissonarrivals/PreciseThroughputTimer.java | 11 ++++++-----
 xdocs/changes.xml                                             |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimer.java
b/src/components/src/main/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimer.java
index 090bd8f..4d482b1 100644
--- a/src/components/src/main/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimer.java
+++ b/src/components/src/main/java/org/apache/jmeter/timers/poissonarrivals/PreciseThroughputTimer.java
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
 public class PreciseThroughputTimer extends AbstractTestElement implements Cloneable, Timer,
TestStateListener, TestBean, ThroughputProvider, DurationProvider {
     private static final Logger log = LoggerFactory.getLogger(PreciseThroughputTimer.class);
 
-    private static final long serialVersionUID = 3;
+    private static final long serialVersionUID = 4;
     private static final ConcurrentMap<AbstractThreadGroup, EventProducer> groupEvents
= new ConcurrentHashMap<>();
 
     /**
@@ -115,17 +115,18 @@ public class PreciseThroughputTimer extends AbstractTestElement implements
Clone
         synchronized (events) {
             nextEvent = events.next();
         }
-        long delay = (long) (nextEvent * TimeUnit.SECONDS.toMillis(1) + testStarted - System.currentTimeMillis());
+        long now = System.currentTimeMillis();
+        long delay = (long) (nextEvent * TimeUnit.SECONDS.toMillis(1) + testStarted - now);
         if (log.isDebugEnabled()) {
             log.debug("Calculated delay is {}", delay);
         }
         delay = Math.max(0, delay);
         long endTime = getThreadContext().getThread().getEndTime();
-        if (endTime > 0 && System.currentTimeMillis() + delay > endTime) {
+        if (endTime > 0 && now + delay > endTime) {
             throw new JMeterStopThreadException("The thread is scheduled to stop in " +
-                    (System.currentTimeMillis() - endTime) + " ms" +
+                    (endTime - now) + " ms" +
                     " and the throughput timer generates a delay of " + delay + "." +
-                    " JMeter (as of 4.0) does not support interrupting of sleeping threads,
thus terminating the thread manually."
+                    " Terminating the thread manually."
             );
         }
         return delay;
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 1cda4ee..75b2ef2 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -245,6 +245,7 @@ invalidated when tree selection changes.</p>
     <li><bug>64142</bug>Presence of DebugPostProcessor in Test plan breaks
ActiveThread Over time in report due to missing information</li>
     <li><bug>64196</bug>Recurse into sub samplers more deeply when checking
assertions</li>
     <li><bug>64196</bug>Recurse into sampleResults for <code>AbstractScopedTestElement#getSampleList</code></li>
+    <li><bug>64381</bug>PreciseThroughputTimer: On termination, log message
contains negative value</li>
 </ul>
 
 <h3>Functions</h3>


Mime
View raw message