[MAGNOLIA-3321] Rotating virtual URI mapping does not return expected values Created: 12/Oct/10  Updated: 20/Feb/15  Resolved: 13/Oct/10

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 4.3.7
Fix Version/s: 4.3.8

Type: Bug Priority: Minor
Reporter: Antti Hietala Assignee: Ondrej Chytil
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

API doc for RotatingVirtualURIMapping says: "An extension of RegexpVirtualURIMapping that allows a rotation between different destination urls. In order to rotate toURI must contain the * that will be replaced by a random number between start (default is 1) and end (default is 3)."

The code does not return random integers between start and end. It returns integers between one and "end minus start".

int randomNumber = RandomUtils.nextInt(end - start) + 1;
start end RandomUtils.nextInt(end - start) + 1
0 3 1...3
1 3 1...2
1 4 1...3
2 5 1...3
3 7 1...4
4 9 1...5

Kindly revise the code to return integers between start and end. This is potentially quite useful.



 Comments   
Comment by Felix Rabe [ 12/Oct/10 ]

The code should read:

int randomNumber = RandomUtils.nextInt(end - start + 1) + start;
Generated at Mon Feb 12 03:45:21 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.