Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2398]Improvement: Fix the warning unchecked generic array creation for varargs parameter of type Class<? extends Throwable>[] #2400

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.google.common.collect.Sets;
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.SystemUtils;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -190,6 +192,9 @@ private void startKerberizedDFS() throws Throwable {
hdfsConf.set("hadoop.proxyuser.hdfs.groups", "*");
hdfsConf.set("hadoop.proxyuser.hdfs.users", "*");

Set<Class<? extends Throwable>> retrySet =
Stream.of(BindException.class).collect(Collectors.toSet());

this.kerberizedDfsCluster =
RetryUtils.retry(
() -> {
Expand Down Expand Up @@ -217,7 +222,7 @@ public MiniDFSCluster run() throws Exception {
},
1000L,
5,
Sets.newHashSet(BindException.class));
retrySet);
}

private void startKDC() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@

package org.apache.uniffle.common.util;

import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.google.common.collect.Sets;
import org.junit.jupiter.api.Test;

import org.apache.uniffle.common.exception.NotRetryException;
import org.apache.uniffle.common.exception.RssException;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class RetryUtilsTest {
class RetryUtilsTest {

@Test
public void testRetryWithCondition() {
void testRetryWithCondition() {
AtomicInteger tryTimes = new AtomicInteger();
AtomicInteger callbackTime = new AtomicInteger();
try {
Expand All @@ -54,11 +56,13 @@ public void testRetryWithCondition() {
}

@Test
public void testRetry() {
void testRetry() {
AtomicInteger tryTimes = new AtomicInteger();
AtomicInteger callbackTime = new AtomicInteger();
int maxTryTime = 3;
try {
Set<Class<? extends Throwable>> retrySet =
Stream.of(RssException.class).collect(Collectors.toSet());
RetryUtils.retry(
() -> {
tryTimes.incrementAndGet();
Expand All @@ -69,7 +73,7 @@ public void testRetry() {
},
10,
maxTryTime,
Sets.newHashSet(RssException.class));
retrySet);
} catch (Throwable throwable) {
// ignore
}
Expand Down
Loading