Skip to content

Commit 7eaad18

Browse files
author
Soroosh Sarabadani
committed
don't case to ParameterizedTypeImpl
1 parent bf2cb03 commit 7eaad18

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

operator-framework/src/main/java/io/javaoperatorsdk/operator/ControllerUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import io.fabric8.kubernetes.client.CustomResourceDoneable;
55
import io.javaoperatorsdk.operator.api.Controller;
66
import io.javaoperatorsdk.operator.api.ResourceController;
7-
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
87

98
import java.lang.reflect.ParameterizedType;
109
import java.util.Arrays;
@@ -14,7 +13,6 @@
1413

1514
public class ControllerUtils {
1615

17-
private final static double JAVA_VERSION = Double.parseDouble(System.getProperty("java.specification.version"));
1816
private static final String FINALIZER_NAME_SUFFIX = "/finalizer";
1917

2018
// this is just to support testing, this way we don't try to create class multiple times in memory with same name.
@@ -36,7 +34,13 @@ static boolean getGenerationEventProcessing(ResourceController controller) {
3634
}
3735

3836
static <R extends CustomResource> Class<R> getCustomResourceClass(ResourceController<R> controller) {
39-
final Class<R> type = Arrays.stream(controller.getClass().getGenericInterfaces()).filter(i -> i instanceof ParameterizedType).map(i -> (ParameterizedTypeImpl) i).findFirst().map(i -> (Class<R>) i.getActualTypeArguments()[0]).get();
37+
final Class<R> type = Arrays
38+
.stream(controller.getClass().getGenericInterfaces())
39+
.filter(i -> i instanceof ParameterizedType)
40+
.map(i -> (ParameterizedType) i)
41+
.findFirst()
42+
.map(i -> (Class<R>) i.getActualTypeArguments()[0])
43+
.get();
4044
return type;
4145
}
4246

0 commit comments

Comments
 (0)