deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject git commit: DELTASPIKE-666 OWB and OEJB containers could throw NullPointerExceptions
Date Wed, 06 Aug 2014 02:22:05 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master d76094f6c -> d74c387d2


DELTASPIKE-666 OWB and OEJB containers could throw NullPointerExceptions


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/d74c387d
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/d74c387d
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/d74c387d

Branch: refs/heads/master
Commit: d74c387d242fe960151462a6c534ec1e1aec614a
Parents: d76094f
Author: John D. Ament <johndament@apache.org>
Authored: Tue Aug 5 22:21:56 2014 -0400
Committer: John D. Ament <johndament@apache.org>
Committed: Tue Aug 5 22:21:56 2014 -0400

----------------------------------------------------------------------
 .../cdise/openejb/OpenEjbContainerControl.java  | 20 +++++++++++++++++---
 .../cdise/owb/OpenWebBeansContainerControl.java |  4 +---
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d74c387d/deltaspike/cdictrl/impl-openejb/src/main/java/org/apache/deltaspike/cdise/openejb/OpenEjbContainerControl.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-openejb/src/main/java/org/apache/deltaspike/cdise/openejb/OpenEjbContainerControl.java
b/deltaspike/cdictrl/impl-openejb/src/main/java/org/apache/deltaspike/cdise/openejb/OpenEjbContainerControl.java
index 5c8f80d..1f5382f 100644
--- a/deltaspike/cdictrl/impl-openejb/src/main/java/org/apache/deltaspike/cdise/openejb/OpenEjbContainerControl.java
+++ b/deltaspike/cdictrl/impl-openejb/src/main/java/org/apache/deltaspike/cdise/openejb/OpenEjbContainerControl.java
@@ -143,9 +143,23 @@ public class OpenEjbContainerControl implements CdiContainer
     {
         if (ctxCtrl == null)
         {
-            Set<Bean<?>> beans = getBeanManager().getBeans(ContextControl.class);
-            ctxCtrlBean = (Bean<ContextControl>) getBeanManager().resolve(beans);
-            ctxCtrlCreationalContext = getBeanManager().createCreationalContext(ctxCtrlBean);
+            BeanManager beanManager = getBeanManager();
+
+            if (beanManager == null)
+            {
+                LOG.warning("If the CDI-container was started by the environment, you can't
use this helper." +
+                        "Instead you can resolve ContextControl manually " +
+                        "(e.g. via BeanProvider.getContextualReference(ContextControl.class)
). " +
+                        "If the container wasn't started already, you have to use CdiContainer#boot
before.");
+
+                return null;
+            }
+            Set<Bean<?>> beans = beanManager.getBeans(ContextControl.class);
+            ctxCtrlBean = (Bean<ContextControl>) beanManager.resolve(beans);
+
+            ctxCtrlCreationalContext = getBeanManager()
+                    .createCreationalContext(ctxCtrlBean);
+
             ctxCtrl = (ContextControl)
                     getBeanManager().getReference(ctxCtrlBean, ContextControl.class, ctxCtrlCreationalContext);
         }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d74c387d/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java
b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java
index 0b11cb3..6b7fe48 100644
--- a/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java
+++ b/deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContainerControl.java
@@ -101,8 +101,6 @@ public class OpenWebBeansContainerControl implements CdiContainer
     {
         if (ctxCtrl == null)
         {
-            Set<Bean<?>> beans = getBeanManager().getBeans(ContextControl.class);
-
             BeanManager beanManager = getBeanManager();
 
             if (beanManager == null)
@@ -114,7 +112,7 @@ public class OpenWebBeansContainerControl implements CdiContainer
 
                 return null;
             }
-
+            Set<Bean<?>> beans = beanManager.getBeans(ContextControl.class);
             ctxCtrlBean = (Bean<ContextControl>) beanManager.resolve(beans);
             ctxCtrlCreationalContext = getBeanManager().createCreationalContext(ctxCtrlBean);
             ctxCtrl = (ContextControl)


Mime
View raw message