-
Notifications
You must be signed in to change notification settings - Fork 234
Closed
Milestone
Description
Describe the bug
This is a regression issue. It's not reproduced on 2.4.11, but reproduced from time to time on 2.4.2. Most likely it is caused by this commit: f073184.
To Reproduce
import net.datafaker.Faker;
public class Main
{
public static void main(String[] args)
{
Faker faker = new Faker();
String result = faker.expression("#{number.number_between '1000','1000'}");
System.out.printf(result);
}
}Expected behavior
The result should be '1000', but it is '1000.0' from time to time.
Versions:
- OS: any
- JDK: no correlation detected
- Faker Version:
2.4.2
Additional context
The methods order is preserved when they are returned from class:
| Method[] classMethods = clazz.getMethods(); |
But then they are stored in HashMap with unpredictable order:
| classMethods.length == 0 ? emptyMap() : new HashMap<>(classMethods.length); |
I see 2 possible solutions:
- rely on method order in the class and use ordered collections to keep sequence - fragile
- improve the algorithm to distinguish double-s vs long-s vs int-s, and search for the method in priority starting from best matching type: e.g. 10 -> int, 10000000000 -> long, 10.0 -> double
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels