Skip to content

Commit

Permalink
fix: avoid NPE when ConstantTimer.delay accesses a variable
Browse files Browse the repository at this point in the history
The variable might not yet be initialized at the first iteration

Fixes #6162
  • Loading branch information
vlsi committed Dec 18, 2023
1 parent 9b250b6 commit 1329c48
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -85,7 +83,7 @@ public double getRange() {
*/
@Override
public long delay() {
return delay;
return getPropertyAsLong(DELAY);
}

/**
Expand All @@ -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);

}
}

0 comments on commit 1329c48

Please sign in to comment.