diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ConfigBeanCreator.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ConfigBeanCreator.java index 548d2afe985c25..03b232b3111bc2 100644 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ConfigBeanCreator.java +++ b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ConfigBeanCreator.java @@ -27,7 +27,7 @@ public Object create(CreationalContext creationalContext, Map> { @Override public Optional create(CreationalContext> creationalContext, Map params) { - InjectionPoint injectionPoint = InjectionPointProvider.get(); + InjectionPoint injectionPoint = InjectionPointProvider.getCurrent(creationalContext); if (injectionPoint == null) { throw new IllegalStateException("No current injection point found"); } diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java index c9df9d7965a50b..f9f94f99b4438b 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java @@ -1305,24 +1305,41 @@ private ResultHandle newInstanceHandle(BeanInfo bean, ClassCreator beanCreator, if (Modifier.isPrivate(constructor.flags())) { privateMembers.add(isApplicationClass, String.format("Bean constructor %s on %s", constructor, constructor.declaringClass().name())); - ResultHandle paramTypesArray = creator.newArray(Class.class, creator.load(providerHandles.size())); - ResultHandle argsArray = creator.newArray(Object.class, creator.load(providerHandles.size())); + int params = providerHandles.size(); + if (providerTypeName.endsWith(DecoratorGenerator.ABSTRACT_IMPL_SUFFIX)) { + params++; + } + ResultHandle paramTypesArray = creator.newArray(Class.class, creator.load(params)); + ResultHandle argsArray = creator.newArray(Object.class, creator.load(params)); for (int i = 0; i < injectionPoints.size(); i++) { creator.writeArrayValue(paramTypesArray, i, creator.loadClass(injectionPoints.get(i).getType().name().toString())); creator.writeArrayValue(argsArray, i, providerHandles.get(i)); } + if (providerTypeName.endsWith(DecoratorGenerator.ABSTRACT_IMPL_SUFFIX)) { + creator.writeArrayValue(paramTypesArray, params - 1, creator.loadClass(CreationalContext.class)); + creator.writeArrayValue(argsArray, params - 1, createMethod.getMethodParam(0)); + } registration.registerMethod(constructor); return creator.invokeStaticMethod(MethodDescriptors.REFLECTIONS_NEW_INSTANCE, creator.loadClass(constructor.declaringClass().name().toString()), paramTypesArray, argsArray); } else { // new SimpleBean(foo) - String[] paramTypes = new String[injectionPoints.size()]; + int params = injectionPoints.size(); + if (providerTypeName.endsWith(DecoratorGenerator.ABSTRACT_IMPL_SUFFIX)) { + params++; + } + String[] paramTypes = new String[params]; for (ListIterator iterator = injectionPoints.listIterator(); iterator.hasNext();) { InjectionPointInfo injectionPoint = iterator.next(); paramTypes[iterator.previousIndex()] = DescriptorUtils.typeToString(injectionPoint.getType()); } + if (providerTypeName.endsWith(DecoratorGenerator.ABSTRACT_IMPL_SUFFIX)) { + paramTypes[params - 1] = CreationalContext.class.getName(); + providerHandles = new ArrayList<>(providerHandles); + providerHandles.add(createMethod.getMethodParam(0)); + } return creator.newInstance(MethodDescriptor.ofConstructor(providerTypeName, paramTypes), providerHandles.toArray(new ResultHandle[0])); } @@ -1332,16 +1349,34 @@ private ResultHandle newInstanceHandle(BeanInfo bean, ClassCreator beanCreator, privateMembers.add(isApplicationClass, String.format("Bean constructor %s on %s", noArgsConstructor, noArgsConstructor.declaringClass().name())); - ResultHandle paramTypesArray = creator.newArray(Class.class, creator.load(0)); - ResultHandle argsArray = creator.newArray(Object.class, creator.load(0)); + ResultHandle paramTypesArray; + ResultHandle argsArray; + if (providerTypeName.endsWith(DecoratorGenerator.ABSTRACT_IMPL_SUFFIX)) { + paramTypesArray = creator.newArray(Class.class, 1); + argsArray = creator.newArray(Object.class, 1); + creator.writeArrayValue(paramTypesArray, 0, creator.loadClass(CreationalContext.class)); + creator.writeArrayValue(argsArray, 0, createMethod.getMethodParam(0)); + } else { + paramTypesArray = creator.newArray(Class.class, 0); + argsArray = creator.newArray(Object.class, 0); + } registration.registerMethod(noArgsConstructor); return creator.invokeStaticMethod(MethodDescriptors.REFLECTIONS_NEW_INSTANCE, creator.loadClass(noArgsConstructor.declaringClass().name().toString()), paramTypesArray, argsArray); } else { + Object[] paramTypes; + ResultHandle[] args; + if (providerTypeName.endsWith(DecoratorGenerator.ABSTRACT_IMPL_SUFFIX)) { + paramTypes = new Object[] { CreationalContext.class }; + args = new ResultHandle[] { createMethod.getMethodParam(0) }; + } else { + paramTypes = new Object[0]; + args = new ResultHandle[0]; + } // new SimpleBean() - return creator.newInstance(MethodDescriptor.ofConstructor(providerTypeName)); + return creator.newInstance(MethodDescriptor.ofConstructor(providerTypeName, paramTypes), args); } } } diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DecoratorGenerator.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DecoratorGenerator.java index 48c92af011388d..f58e83e39e82db 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DecoratorGenerator.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DecoratorGenerator.java @@ -5,6 +5,7 @@ import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -16,6 +17,8 @@ import java.util.function.Predicate; import java.util.function.Supplier; +import jakarta.enterprise.context.spi.CreationalContext; + import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; @@ -171,8 +174,13 @@ private String generateDecoratorImplementation(String baseName, String targetPac // Constructor MethodInfo decoratorConstructor = decoratorClass.firstMethod(Methods.INIT); + List decoratorConstructorParams = new ArrayList<>(); + for (org.jboss.jandex.Type parameterType : decoratorConstructor.parameterTypes()) { + decoratorConstructorParams.add(parameterType.name().toString()); + } + decoratorConstructorParams.add(CreationalContext.class.getName()); MethodCreator constructor = decoratorImplCreator.getMethodCreator(Methods.INIT, "V", - decoratorConstructor.parameterTypes().stream().map(it -> it.name().toString()).toArray()); + decoratorConstructorParams.toArray(new Object[0])); ResultHandle[] constructorArgs = new ResultHandle[decoratorConstructor.parametersCount()]; for (int i = 0; i < decoratorConstructor.parametersCount(); i++) { constructorArgs[i] = constructor.getMethodParam(i); @@ -181,7 +189,8 @@ private String generateDecoratorImplementation(String baseName, String targetPac constructor.invokeSpecialMethod(decoratorConstructor, constructor.getThis(), constructorArgs); // Set the delegate field constructor.writeInstanceField(delegateField.getFieldDescriptor(), constructor.getThis(), - constructor.invokeStaticMethod(MethodDescriptors.DECORATOR_DELEGATE_PROVIDER_GET)); + constructor.invokeStaticMethod(MethodDescriptors.DECORATOR_DELEGATE_PROVIDER_GET, + constructor.getMethodParam(decoratorConstructor.parametersCount()))); constructor.returnValue(null); // Find non-decorated methods from all decorated types diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java index 79b2f7af860b2e..ebccb00134a45c 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java @@ -287,14 +287,11 @@ public final class MethodDescriptors { public static final MethodDescriptor CLIENT_PROXIES_GET_DELEGATE = MethodDescriptor.ofMethod(ClientProxies.class, "getDelegate", Object.class, InjectableBean.class); - public static final MethodDescriptor DECORATOR_DELEGATE_PROVIDER_SET = MethodDescriptor - .ofMethod(DecoratorDelegateProvider.class, "set", Object.class, Object.class); + public static final MethodDescriptor DECORATOR_DELEGATE_PROVIDER_GET = MethodDescriptor.ofMethod( + DecoratorDelegateProvider.class, "getCurrent", Object.class, CreationalContext.class); - public static final MethodDescriptor DECORATOR_DELEGATE_PROVIDER_UNSET = MethodDescriptor - .ofMethod(DecoratorDelegateProvider.class, "unset", void.class); - - public static final MethodDescriptor DECORATOR_DELEGATE_PROVIDER_GET = MethodDescriptor - .ofMethod(DecoratorDelegateProvider.class, "get", Object.class); + public static final MethodDescriptor DECORATOR_DELEGATE_PROVIDER_SET = MethodDescriptor.ofMethod( + DecoratorDelegateProvider.class, "setCurrent", Object.class, CreationalContext.class, Object.class); public static final MethodDescriptor INSTANCES_LIST_OF = MethodDescriptor .ofMethod(Instances.class, "listOf", List.class, InjectableBean.class, Type.class, Type.class, diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/SubclassGenerator.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/SubclassGenerator.java index 1574f72bc58be4..04b8bc44075efa 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/SubclassGenerator.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/SubclassGenerator.java @@ -817,12 +817,14 @@ && isDecorated(decoratedMethodDescriptors, methodDescriptor, resolvedMethodDescr } ResultHandle delegateSubclassInstance = subclassConstructor.newInstance(MethodDescriptor.ofConstructor( delegateSubclass.getClassName(), constructorParameterTypes.toArray(new String[0])), paramHandles); - subclassConstructor.invokeStaticMethod(MethodDescriptors.DECORATOR_DELEGATE_PROVIDER_SET, delegateSubclassInstance); + ResultHandle prev = subclassConstructor.invokeStaticMethod( + MethodDescriptors.DECORATOR_DELEGATE_PROVIDER_SET, creationalContext, delegateSubclassInstance); ResultHandle decoratorInstance = subclassConstructor.invokeInterfaceMethod( MethodDescriptors.INJECTABLE_REF_PROVIDER_GET, constructorMethodParam, creationalContext); // And unset the delegate IP afterwards - subclassConstructor.invokeStaticMethod(MethodDescriptors.DECORATOR_DELEGATE_PROVIDER_UNSET); + subclassConstructor.invokeStaticMethod( + MethodDescriptors.DECORATOR_DELEGATE_PROVIDER_SET, creationalContext, prev); decoratorToResultHandle.put(decorator.getIdentifier(), decoratorInstance); diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcContainerImpl.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcContainerImpl.java index 94d6c17e59d128..25e8e75258b5d5 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcContainerImpl.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcContainerImpl.java @@ -553,14 +553,14 @@ static InstanceHandle beanInstanceHandle(InjectableBean bean, Creation } InjectionPoint prev = null; if (resetCurrentInjectionPoint) { - prev = InjectionPointProvider.set(CurrentInjectionPointProvider.EMPTY); + prev = InjectionPointProvider.setCurrent(creationalContext, CurrentInjectionPointProvider.EMPTY); } try { return new EagerInstanceHandle<>(bean, bean.get(creationalContext), creationalContext, parentContext, destroyLogic); } finally { if (resetCurrentInjectionPoint) { - InjectionPointProvider.set(prev); + InjectionPointProvider.setCurrent(creationalContext, prev); } } } else { diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java index 72d4853101f833..9527ac27ae1c58 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java @@ -62,12 +62,12 @@ public Object getReference(Bean bean, Type beanType, CreationalContext ctx if (bean instanceof InjectableBean && ctx instanceof CreationalContextImpl) { // there's no actual injection point or an `Instance` object, // the "current" injection point must be `null` - InjectionPoint prev = InjectionPointProvider.set(null); + InjectionPoint prev = InjectionPointProvider.setCurrent(ctx, null); try { return ArcContainerImpl.beanInstanceHandle((InjectableBean) bean, (CreationalContextImpl) ctx, false, null, true).get(); } finally { - InjectionPointProvider.set(prev); + InjectionPointProvider.setCurrent(ctx, prev); } } throw new IllegalArgumentException( @@ -86,12 +86,12 @@ public Object getInjectableReference(InjectionPoint ij, CreationalContext ctx throw new UnsatisfiedResolutionException(); } InjectableBean bean = (InjectableBean) resolve(beans); - InjectionPoint prev = InjectionPointProvider.set(ij); + InjectionPoint prev = InjectionPointProvider.setCurrent(ctx, ij); try { return ArcContainerImpl.beanInstanceHandle(bean, (CreationalContextImpl) ctx, false, null, true).get(); } finally { - InjectionPointProvider.set(prev); + InjectionPointProvider.setCurrent(ctx, prev); } } throw new IllegalArgumentException( diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java index 5de156b6170d51..43b6c612db3c85 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java @@ -7,6 +7,7 @@ import jakarta.enterprise.context.spi.Contextual; import jakarta.enterprise.context.spi.CreationalContext; +import jakarta.enterprise.inject.spi.InjectionPoint; import io.quarkus.arc.InjectableBean; import io.quarkus.arc.InjectableReferenceProvider; @@ -24,6 +25,9 @@ public class CreationalContextImpl implements CreationalContext, Function< private final CreationalContextImpl parent; private List> dependentInstances; + private InjectionPoint currentInjectionPoint; + private Object currentDecoratorDelegate; + public CreationalContextImpl(Contextual contextual) { this(contextual, null); } @@ -129,4 +133,50 @@ public static void addDependencyToParent(InjectableBean bean, I instance, } } + static InjectionPoint getCurrentInjectionPoint(CreationalContext ctx) { + CreationalContextImpl instance = unwrap(ctx); + while (instance != null) { + synchronized (instance) { + InjectionPoint result = instance.currentInjectionPoint; + if (result != null) { + return result; + } + } + instance = instance.parent; + } + return null; + } + + static InjectionPoint setCurrentInjectionPoint(CreationalContext ctx, InjectionPoint injectionPoint) { + CreationalContextImpl instance = unwrap(ctx); + synchronized (instance) { + InjectionPoint previous = instance.currentInjectionPoint; + instance.currentInjectionPoint = injectionPoint; + return previous; + } + } + + static Object getCurrentDecoratorDelegate(CreationalContext ctx) { + CreationalContextImpl instance = unwrap(ctx); + while (instance != null) { + synchronized (instance) { + Object result = instance.currentDecoratorDelegate; + if (result != null) { + return result; + } + } + instance = instance.parent; + } + return null; + } + + static Object setCurrentDecoratorDelegate(CreationalContext ctx, Object decoratorDelegate) { + CreationalContextImpl instance = unwrap(ctx); + synchronized (instance) { + Object previous = instance.currentDecoratorDelegate; + instance.currentDecoratorDelegate = decoratorDelegate; + return previous; + } + } + } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CurrentInjectionPointProvider.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CurrentInjectionPointProvider.java index 6b3f020fc9481a..76a368267c4725 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CurrentInjectionPointProvider.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CurrentInjectionPointProvider.java @@ -43,11 +43,11 @@ public CurrentInjectionPointProvider(InjectableBean bean, Supplier creationalContext) { - InjectionPoint prev = InjectionPointProvider.set(injectionPoint); + InjectionPoint prev = InjectionPointProvider.setCurrent(creationalContext, injectionPoint); try { return delegateSupplier.get().get(creationalContext); } finally { - InjectionPointProvider.set(prev); + InjectionPointProvider.setCurrent(creationalContext, prev); } } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/DecoratorDelegateProvider.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/DecoratorDelegateProvider.java index d7ef2fede1a11d..f2a27f12767eee 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/DecoratorDelegateProvider.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/DecoratorDelegateProvider.java @@ -6,40 +6,22 @@ public class DecoratorDelegateProvider implements InjectableReferenceProvider { - private static final ThreadLocal CURRENT = new ThreadLocal<>(); - @Override public Object get(CreationalContext creationalContext) { - return CURRENT.get(); + return getCurrent(creationalContext); + } + + static Object getCurrent(CreationalContext ctx) { + return CreationalContextImpl.getCurrentDecoratorDelegate(ctx); } /** - * Set the current delegate for a non-null parameter, remove the threadlocal for null parameter. + * Set the current delegate for a non-null parameter, or remove it for null parameter. * - * @param delegate * @return the previous delegate or {@code null} */ - public static Object set(Object delegate) { - if (delegate != null) { - Object prev = CURRENT.get(); - if (delegate.equals(prev)) { - return delegate; - } else { - CURRENT.set(delegate); - return prev; - } - } else { - CURRENT.remove(); - return null; - } - } - - public static void unset() { - set(null); - } - - public static Object get() { - return CURRENT.get(); + static Object setCurrent(CreationalContext ctx, Object delegate) { + return CreationalContextImpl.setCurrentDecoratorDelegate(ctx, delegate); } } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/EventBean.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/EventBean.java index a67ea603cc11dd..0b1a67c849e3af 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/EventBean.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/EventBean.java @@ -19,7 +19,7 @@ public Set getTypes() { @Override public Event get(CreationalContext> creationalContext) { // Obtain current IP to get the required type and qualifiers - InjectionPoint ip = InjectionPointProvider.get(); + InjectionPoint ip = InjectionPointProvider.getCurrent(creationalContext); return new EventImpl<>(ip.getType(), ip.getQualifiers(), ip); } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectionPointBean.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectionPointBean.java index 0163206d6ca7c6..7cb2c87660d918 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectionPointBean.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectionPointBean.java @@ -16,7 +16,7 @@ public Set getTypes() { @Override public InjectionPoint get(CreationalContext creationalContext) { - return InjectionPointProvider.get(); + return InjectionPointProvider.getCurrent(creationalContext); } @Override diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectionPointProvider.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectionPointProvider.java index 5dd28847b94b04..258bb34813f0ea 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectionPointProvider.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectionPointProvider.java @@ -11,36 +11,23 @@ */ public class InjectionPointProvider implements InjectableReferenceProvider { - private static final ThreadLocal CURRENT = new ThreadLocal<>(); - @Override public InjectionPoint get(CreationalContext creationalContext) { - return CURRENT.get(); + return getCurrent(creationalContext); + } + + // `public` because of some consumers outside ArC + public static InjectionPoint getCurrent(CreationalContext ctx) { + return CreationalContextImpl.getCurrentInjectionPoint(ctx); } /** - * Set the current injection point for a non-null parameter, remove the threadlocal for null parameter. + * Set the current injection point for a non-null parameter, or remove it for null parameter. * - * @param injectionPoint * @return the previous injection point or {@code null} */ - static InjectionPoint set(InjectionPoint injectionPoint) { - if (injectionPoint != null) { - InjectionPoint prev = InjectionPointProvider.CURRENT.get(); - if (injectionPoint.equals(prev)) { - return injectionPoint; - } else { - InjectionPointProvider.CURRENT.set(injectionPoint); - return prev; - } - } else { - CURRENT.remove(); - return null; - } - } - - public static InjectionPoint get() { - return CURRENT.get(); + static InjectionPoint setCurrent(CreationalContext ctx, InjectionPoint ip) { + return CreationalContextImpl.setCurrentInjectionPoint(ctx, ip); } } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceBean.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceBean.java index 0fc33ce7e6c964..7580d82d48e39f 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceBean.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceBean.java @@ -30,7 +30,7 @@ public Class getBeanClass() { @Override public Instance get(CreationalContext> creationalContext) { // Obtain current IP to get the required type and qualifiers - InjectionPoint ip = InjectionPointProvider.get(); + InjectionPoint ip = InjectionPointProvider.getCurrent(creationalContext); InstanceImpl> instance = InstanceImpl.forInjection((InjectableBean) ip.getBean(), ip.getType(), ip.getQualifiers(), (CreationalContextImpl) creationalContext, Collections.EMPTY_SET, ip.getMember(), 0, ip.isTransient()); diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java index 4c84a064e46d40..2ce4864251c0a3 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java @@ -264,14 +264,14 @@ private InstanceHandle getHandle(InjectableBean bean) { public H get() { InjectionPoint prev = null; if (resetCurrentInjectionPoint) { - prev = InjectionPointProvider.set(new InjectionPointImpl(injectionPointType, requiredType, + prev = InjectionPointProvider.setCurrent(context, new InjectionPointImpl(injectionPointType, requiredType, requiredQualifiers, targetBean, annotations, javaMember, position, isTransient)); } try { return bean.get(context); } finally { if (resetCurrentInjectionPoint) { - InjectionPointProvider.set(prev); + InjectionPointProvider.setCurrent(context, prev); } } } @@ -317,7 +317,7 @@ private T getBeanInstance(InjectableBean bean) { CreationalContextImpl ctx = creationalContext.child(bean); InjectionPoint prev = null; if (resetCurrentInjectionPoint) { - prev = InjectionPointProvider.set(new InjectionPointImpl(injectionPointType, requiredType, + prev = InjectionPointProvider.setCurrent(ctx, new InjectionPointImpl(injectionPointType, requiredType, requiredQualifiers, targetBean, annotations, javaMember, position, isTransient)); } T instance; @@ -325,7 +325,7 @@ private T getBeanInstance(InjectableBean bean) { instance = bean.get(ctx); } finally { if (resetCurrentInjectionPoint) { - InjectionPointProvider.set(prev); + InjectionPointProvider.setCurrent(ctx, prev); } } return instance; diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Instances.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Instances.java index 66c7f7b1b8261d..f65b917fd3f5de 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Instances.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Instances.java @@ -67,15 +67,14 @@ public static List listOf(InjectableBean targetBean, Type injectionPoi return Collections.emptyList(); } List list = new ArrayList<>(beans.size()); - InjectionPoint prev = InjectionPointProvider - .set(new InjectionPointImpl(injectionPointType, requiredType, requiredQualifiers, targetBean, - annotations, javaMember, position, isTransient)); + InjectionPoint prev = InjectionPointProvider.setCurrent(creationalContext, new InjectionPointImpl(injectionPointType, + requiredType, requiredQualifiers, targetBean, annotations, javaMember, position, isTransient)); try { for (InjectableBean bean : beans) { list.add(getBeanInstance(CreationalContextImpl.unwrap(creationalContext), (InjectableBean) bean)); } } finally { - InjectionPointProvider.set(prev); + InjectionPointProvider.setCurrent(creationalContext, prev); } return List.copyOf(list); @@ -126,12 +125,11 @@ private static InstanceHandle getHandle(CreationalContextImpl parent, @Override public T get() { - InjectionPoint prev = InjectionPointProvider - .set(injectionPointSupplier.get()); + InjectionPoint prev = InjectionPointProvider.setCurrent(ctx, injectionPointSupplier.get()); try { return bean.get(ctx); } finally { - InjectionPointProvider.set(prev); + InjectionPointProvider.setCurrent(ctx, prev); } } }, null);