RandomDate ignores inclusive end date and throws when start == end

Open Beginner friendly
#6,609 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java
Domain
testing-qa

Research direction

Start by locating the __RandomDate function implementation and reproduce the two calls described in the issue, including the single-date case. Update the behavior so the configured end date can be returned and equal start and end dates succeed, then add or run tests covering both cases.

Written by the indexing model from the issue text.

Description

defect to-triage
Expected behavior

The __RandomDate function should treat the provided end date as inclusive. When the start and end dates are the same, the function should simply return that single date (and store it in the target variable) instead of failing.

Actual behavior
  • When startDate < endDate, the function never returns the configured end date. It behaves as if the interval were [start, end) (exclusive upper bound).

  • When startDate == endDate, the call to ThreadLocalRandom.nextLong(start, end) raises IllegalArgumentException: bound must be greater than origin, so the function errors out instead of returning the only valid date.

Steps to reproduce the problem
  1. Create a test plan with a Debug Sampler and a Simple Data Writer (or just watch the Debug Sampler output).
  2. Add a User Parameters or a JSR223 Sampler to evaluate ${__RandomDate(yyyy-MM-dd,2111-03-29,2111-03-30,,MY_VAR)}.
  3. Run the plan multiple times. Observe that the logged value is always 2111-03-29 and MY_VAR never contains 2111-03-30.
  4. Change the call to ${__RandomDate(yyyy-MM-dd,2111-03-29,2111-03-29,,MY_VAR)} and run again. The sampler now fails with the IllegalArgumentException mentioned above.
JMeter Version

6.0.0-SNAPSHOT

Java Version

OpenJDK Runtime Environment 21.0.8 (2025-07-16)

OS Version

Linux 6.6.87.2-microsoft-standard-WSL2 (running under Windows 11 / WSL2)

Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/jmeter

All issues in apache/jmeter

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.