package io.quarkus.arc.impl;

import io.quarkus.arc.InjectableReferenceProvider;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.InjectionPoint;

/**
 *
 * @author Martin Kouba
 */
public class InjectionPointProvider implements InjectableReferenceProvider<InjectionPoint> {

    private static final ThreadLocal<InjectionPoint> CURRENT = new ThreadLocal<>();

    @Override
    public InjectionPoint get(CreationalContext<InjectionPoint> creationalContext) {
        return CURRENT.get();
    }

    /**
     * Set the current injection point for a non-null parameter, remove the threadlocal 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();
            InjectionPointProvider.CURRENT.set(injectionPoint);
            return prev;
        } else {
            CURRENT.remove();
            return null;
        }
    }

    public static InjectionPoint get() {
        return CURRENT.get();
    }

}

@@ -921,24 +921,135 @@
 RENT.get();%0A
+            if (injectionPoint.equals(prev)) %7B%0A                return injectionPoint;%0A            %7D else %7B%0A    
             
@@ -1108,24 +1108,28 @@
             
+    
 return prev;
@@ -1129,16 +1129,30 @@
 n prev;%0A
+            %7D%0A
         

Check to see if injection point is same as current thread local value