-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix flaky tests with Locality and TimeTest
* flaky test TimeTest Sometimes if failed when "now + 1 minute" was in tomorrow. For example: java.lang.IllegalArgumentException: Invalid time range: the upper bound time (00:00:47.593917390) is before the lower bound (23:59:47.593917390) * flaky test with Locality Sometimes if failed when two parallel threads modify field `shuffledLocales`. For example: ``` net.datafaker.integration.FakerRepeatabilityIntegrationTest.shouldCreateUniqueValues -- Time elapsed: 0.890 s <<< ERROR! java.lang.IndexOutOfBoundsException: Index 69 out of bounds for length 69 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.base/java.util.Objects.checkIndex(Objects.java:361) at java.base/java.util.ArrayList.remove(ArrayList.java:504) at net.datafaker.providers.base.Locality.localeStringWithoutReplacement(Locality.java:174) at net.datafaker.providers.base.Locality.localeStringWithoutReplacement(Locality.java:156) ``` * optimize memory usage by Locality.shuffledLocales it's not needed to remove the element from shuffledLocales and resize the underlying array. It's enough just to keep an index of current element in this list.
- Loading branch information
Showing
3 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters