Skip to content

Commit 3e80db4

Browse files
committed
fix: more robust resolution of associated custom resource type
1 parent ef84ffb commit 3e80db4

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

operator-framework-quarkus-extension/deployment/src/main/java/io/javaoperatorsdk/quarkus/extension/deployment/QuarkusExtensionProcessor.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.quarkus.deployment.builditem.FeatureBuildItem;
2626
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
2727
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
28+
import io.quarkus.deployment.util.JandexUtil;
2829
import java.util.List;
2930
import java.util.Optional;
3031
import java.util.function.Function;
@@ -36,7 +37,7 @@
3637
import org.jboss.jandex.AnnotationValue;
3738
import org.jboss.jandex.ClassInfo;
3839
import org.jboss.jandex.DotName;
39-
import org.jboss.jandex.Type;
40+
import org.jboss.jandex.IndexView;
4041
import org.jboss.logging.Logger;
4142

4243
class QuarkusExtensionProcessor {
@@ -78,7 +79,7 @@ void createConfigurationServiceAndOperator(
7879

7980
final List<ControllerConfiguration> controllerConfigs =
8081
resourceControllers.stream()
81-
.map(ci -> createControllerConfiguration(ci, additionalBeans, reflectionClasses))
82+
.map(ci -> createControllerConfiguration(ci, additionalBeans, reflectionClasses, index))
8283
.collect(Collectors.toList());
8384

8485
final var version = Utils.loadFromProperties();
@@ -101,17 +102,14 @@ void createConfigurationServiceAndOperator(
101102
private ControllerConfiguration createControllerConfiguration(
102103
ClassInfo info,
103104
BuildProducer<AdditionalBeanBuildItem> additionalBeans,
104-
BuildProducer<ReflectiveClassBuildItem> reflectionClasses) {
105+
BuildProducer<ReflectiveClassBuildItem> reflectionClasses,
106+
IndexView index) {
105107
// first retrieve the custom resource class
106-
final var rcInterface =
107-
info.interfaceTypes().stream()
108-
.filter(t -> t.name().equals(RESOURCE_CONTROLLER))
109-
.findFirst()
110-
.map(Type::asParameterizedType)
111-
// shouldn't happen since we're only dealing with ResourceController implementors
112-
// already
113-
.orElseThrow();
114-
final var crType = rcInterface.arguments().get(0).name().toString();
108+
final var crType =
109+
JandexUtil.resolveTypeParameters(info.name(), RESOURCE_CONTROLLER, index)
110+
.get(0)
111+
.name()
112+
.toString();
115113

116114
// create ResourceController bean
117115
final var resourceControllerClassName = info.name().toString();

0 commit comments

Comments
 (0)