You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by ta...@apache.org on 2019/05/22 13:51:36 UTC

[deltaspike] branch master updated: Fix an issue which causes "Argument bean must not be null". When lazyInit() is called concurrently, the first thread should be the only one to initialize it; however, deltaSpikeProxyInvocationHandler has been assigned before all initialization jobs are completed, which sometimes causes issue.

This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/deltaspike.git


The following commit(s) were added to refs/heads/master by this push:
     new c5ab0d6  Fix an issue which causes "Argument bean must not be null". When lazyInit() is called concurrently, the first thread should be the only one to initialize it; however, deltaSpikeProxyInvocationHandler has been assigned before all initialization jobs are completed, which sometimes causes issue.
     new d0e6edf  Merge pull request #90 from jw941/master
c5ab0d6 is described below

commit c5ab0d6672850abdb846dc93f22c180adf651339
Author: Frank Wang <fr...@britensw.com.au>
AuthorDate: Wed May 22 09:50:29 2019 +1000

    Fix an issue which causes "Argument bean must not be null". When lazyInit() is called concurrently, the first thread should be the only one to initialize it; however, deltaSpikeProxyInvocationHandler has been assigned before all initialization jobs are completed, which sometimes causes issue.
---
 .../proxy/api/DeltaSpikeProxyContextualLifecycle.java      | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyContextualLifecycle.java b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyContextualLifecycle.java
index c06aeef..d250440 100644
--- a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyContextualLifecycle.java
+++ b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyContextualLifecycle.java
@@ -52,11 +52,11 @@ public class DeltaSpikeProxyContextualLifecycle<T, H extends InvocationHandler>
     private final Class<T> targetClass;
     private final BeanManager beanManager;
     
-    private DeltaSpikeProxyInvocationHandler deltaSpikeProxyInvocationHandler;
+    private volatile DeltaSpikeProxyInvocationHandler deltaSpikeProxyInvocationHandler;
     
-    private InjectionTarget<T> injectionTarget;
-    private Bean<H> handlerBean;
-    private CreationalContext<?> creationalContextOfDependentHandler;
+    private volatile InjectionTarget<T> injectionTarget;
+    private volatile Bean<H> handlerBean;
+    private volatile CreationalContext<?> creationalContextOfDependentHandler;
 
     public DeltaSpikeProxyContextualLifecycle(Class<T> targetClass,
                                               Class<H> delegateInvocationHandlerClass,
@@ -141,9 +141,6 @@ public class DeltaSpikeProxyContextualLifecycle<T, H extends InvocationHandler>
     {
         if (this.deltaSpikeProxyInvocationHandler == null)
         {
-            this.deltaSpikeProxyInvocationHandler = BeanProvider.getContextualReference(
-                    beanManager, DeltaSpikeProxyInvocationHandler.class, false);
-
             Set<Bean<H>> handlerBeans = BeanProvider.getBeanDefinitions(
                     delegateInvocationHandlerClass, false, true, beanManager);
             if (handlerBeans.size() != 1)
@@ -167,6 +164,9 @@ public class DeltaSpikeProxyContextualLifecycle<T, H extends InvocationHandler>
                         + delegateInvocationHandlerClass + " found beans: " + beanInfo.toString());
             }
             this.handlerBean = handlerBeans.iterator().next();
+
+            this.deltaSpikeProxyInvocationHandler = BeanProvider.getContextualReference(
+                    beanManager, DeltaSpikeProxyInvocationHandler.class, false);
         }
     }