You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2019/07/30 13:10:49 UTC

[myfaces] branch 2.3.x updated: MYFACES-4299

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

tandraschko pushed a commit to branch 2.3.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/2.3.x by this push:
     new bcf35ba  MYFACES-4299
bcf35ba is described below

commit bcf35bafbeb75ca276e3a999e2d73c975f0cd789
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Tue Jul 30 15:10:40 2019 +0200

    MYFACES-4299
---
 .../myfaces/cdi/managedproperty/ManagedPropertyProducer.java       | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/impl/src/main/java/org/apache/myfaces/cdi/managedproperty/ManagedPropertyProducer.java b/impl/src/main/java/org/apache/myfaces/cdi/managedproperty/ManagedPropertyProducer.java
index 4c07584..b3c3e27 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/managedproperty/ManagedPropertyProducer.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/managedproperty/ManagedPropertyProducer.java
@@ -24,6 +24,7 @@ import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.util.AnnotationLiteral;
+import javax.faces.FacesException;
 import javax.faces.annotation.ManagedProperty;
 import javax.faces.context.FacesContext;
 import org.apache.myfaces.cdi.util.AbstractDynamicProducer;
@@ -80,6 +81,12 @@ public class ManagedPropertyProducer extends AbstractDynamicProducer<Object>
     protected Object createManagedProperty(CreationalContext<Object> cc, ManagedPropertyInfo typeInfo)
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
+        if (facesContext == null)
+        {
+            throw new FacesException("@ManagedProperty(\"" + typeInfo.getExpression()
+                    + "\") can only be resolved in a JSF request!");
+        }
+        
         return facesContext.getApplication().evaluateExpressionGet(
                 facesContext, typeInfo.getExpression(), getBeanClass());
     }