Skip to content

Commit

Permalink
[java] Use thread-safe random generator
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Mar 11, 2024
1 parent 0689f84 commit 0e38d2f
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -18,10 +18,14 @@
package org.openqa.selenium.bidi.storage;

import static org.assertj.core.api.Assertions.assertThat;
import static org.openqa.selenium.testing.Safely.safelyCall;

import java.time.Instant;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Cookie;
Expand All @@ -33,7 +37,7 @@

class StorageCommandsTest extends JupiterTestBase {
private String cookiePage;
private static final Random random = new Random();
private static final Random random = ThreadLocalRandom.current();

private Storage storage;

Expand Down Expand Up @@ -288,6 +292,13 @@ public void testAddCookiesWithDifferentPathsThatAreRelatedToOurs() {
assertCookieIsNotPresentWithName("fish");
}

@AfterEach
public void quitDriver() {
if (driver != null) {
driver.quit();
}
}

private String generateUniqueKey() {
return String.format("key_%d", random.nextInt());
}
Expand Down

0 comments on commit 0e38d2f

Please sign in to comment.