apache / apache/jmeter

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

Open
#6,609 4 comments 0 reactions 0 assignees View on GitHub
defect to-triage
Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Description

### 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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.