From 1329c481fc9def6ad81f3534e86a44f584e221a9 Mon Sep 17 00:00:00 2001 From: Vladimir Sitnikov Date: Mon, 18 Dec 2023 18:05:38 +0300 Subject: [PATCH] fix: avoid NPE when ConstantTimer.delay accesses a variable The variable might not yet be initialized at the first iteration Fixes https://github.com/apache/jmeter/issues/6162 --- .../org/apache/jmeter/timers/ConstantTimer.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/components/src/main/java/org/apache/jmeter/timers/ConstantTimer.java b/src/components/src/main/java/org/apache/jmeter/timers/ConstantTimer.java index c62d226bf27..8d9790db19e 100644 --- a/src/components/src/main/java/org/apache/jmeter/timers/ConstantTimer.java +++ b/src/components/src/main/java/org/apache/jmeter/timers/ConstantTimer.java @@ -29,14 +29,12 @@ * value update and user interaction. * */ -public class ConstantTimer extends AbstractTestElement implements Timer, Serializable, LoopIterationListener { +public class ConstantTimer extends AbstractTestElement implements Timer, Serializable { private static final long serialVersionUID = 240L; public static final String DELAY = "ConstantTimer.delay"; //$NON-NLS-1$ - private long delay = 0; - /** * No-arg constructor. */ @@ -85,7 +83,7 @@ public double getRange() { */ @Override public long delay() { - return delay; + return getPropertyAsLong(DELAY); } /** @@ -97,15 +95,4 @@ public long delay() { public String toString() { return JMeterUtils.getResString("constant_timer_memo"); //$NON-NLS-1$ } - - /** - * Gain access to any variables that have been defined. - * - * @see LoopIterationListener#iterationStart(LoopIterationEvent) - */ - @Override - public void iterationStart(LoopIterationEvent event) { - delay = getPropertyAsLong(DELAY); - - } }