From 17cfc18252658dc5767b9c34c0576ac87e00f158 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 10 Jun 2021 14:56:10 +0200 Subject: [PATCH] Amazon Services - Unwrap Instance when inspecting injection points Fixes #15213 --- .../AbstractAmazonServiceProcessor.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AbstractAmazonServiceProcessor.java b/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AbstractAmazonServiceProcessor.java index fbd2655255b76e..7f2886b6ee4ff9 100644 --- a/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AbstractAmazonServiceProcessor.java +++ b/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AbstractAmazonServiceProcessor.java @@ -7,6 +7,7 @@ import javax.enterprise.context.ApplicationScoped; import org.jboss.jandex.DotName; +import org.jboss.jandex.ParameterizedType; import org.jboss.jandex.Type; import io.quarkus.amazon.common.runtime.AmazonClientApacheTransportRecorder; @@ -22,6 +23,7 @@ import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.arc.processor.BuildExtension; +import io.quarkus.arc.processor.DotNames; import io.quarkus.arc.processor.InjectionPointInfo; import io.quarkus.deployment.Feature; import io.quarkus.deployment.annotations.BuildProducer; @@ -61,14 +63,12 @@ protected void setupExtension(BeanRegistrationPhaseBuildItem beanRegistrationPha //Discover all clients injections in order to determine if async or sync client is required for (InjectionPointInfo injectionPoint : beanRegistrationPhase.getContext().get(BuildExtension.Key.INJECTION_POINTS)) { - Type requiredType = injectionPoint.getRequiredType(); - - System.out.println(requiredType); + Type injectedType = getInjectedType(injectionPoint); - if (syncClientName().equals(requiredType.name())) { + if (syncClientName().equals(injectedType.name())) { syncClassName = Optional.of(syncClientName()); } - if (asyncClientName().equals(requiredType.name())) { + if (asyncClientName().equals(injectedType.name())) { asyncClassName = Optional.of(asyncClientName()); } } @@ -205,4 +205,15 @@ protected void createClientBuilders( .done()); } } + + private Type getInjectedType(InjectionPointInfo injectionPoint) { + Type requiredType = injectionPoint.getRequiredType(); + Type injectedType = requiredType; + + if (DotNames.INSTANCE.equals(requiredType.name()) && requiredType instanceof ParameterizedType) { + injectedType = requiredType.asParameterizedType().arguments().get(0); + } + + return injectedType; + } }