CASSJAVA-40: Driver testing against Java 21 by SiyaoIsHiding · Pull Request #1999 · apache/cassandra-java-driver · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jenkinsfile-asf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.datastax.oss.driver.internal.core.util;

import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

public class ArrayUtils {
Expand Down Expand Up @@ -77,7 +78,7 @@ public static <ElementT> void shuffleHead(@NonNull ElementT[] elements, int n) {
* Fisher-Yates shuffle</a>
*/
public static <ElementT> void shuffleHead(
@NonNull ElementT[] elements, int n, @NonNull ThreadLocalRandom random) {
@NonNull ElementT[] elements, int n, @NonNull Random random) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mockito says they can no longer support mocking of ThreadLocalRandom.
This fix will also close JAVA-3137.

if (n > elements.length) {
throw new ArrayIndexOutOfBoundsException(
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class QueryTraceFetcherTest {
@Mock private NettyOptions nettyOptions;
@Mock private EventExecutorGroup adminEventExecutorGroup;
@Mock private EventExecutor eventExecutor;
@Mock private InetAddress address;
private InetAddress address = InetAddress.getLoopbackAddress();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mockito can no longer mock InetAddress as it becomes final in newer JDK versions.


@Captor private ArgumentCaptor<SimpleStatement> statementCaptor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.concurrent.ThreadLocalRandom;
import java.util.Random;
import org.junit.Test;

public class ArrayUtilsTest {
Expand Down Expand Up @@ -86,7 +86,7 @@ public void should_not_bubble_down_when_target_index_lower() {
@Test
public void should_shuffle_head() {
String[] array = {"a", "b", "c", "d", "e"};
ThreadLocalRandom random = mock(ThreadLocalRandom.class);
Random random = mock(Random.class);
when(random.nextInt(anyInt()))
.thenAnswer(
(invocation) -> {
Expand Down
13 changes: 13 additions & 0 deletions pom.xml