James McLeod created MYFACES-4633:
-------------------------------------

             Summary: Suspicious Logic when setting BeanManager from JNDI
                 Key: MYFACES-4633
                 URL: https://issues.apache.org/jira/browse/MYFACES-4633
             Project: MyFaces Core
          Issue Type: Bug
            Reporter: James McLeod
         Attachments: beanmanager-init-from-jndi.patch

Function {{private}} BeanManager lookupBeanManagerFromJndi() in 
[FacesInitializerImpl|https://github.com/apache/myfaces/blob/main/impl/src/main/java/org/apache/myfaces/webapp/FacesInitializerImpl.java]
 (specifically [line 594 of the current 
version|https://github.com/apache/myfaces/blob/7905297aee87def27bd77975e07545f2e59aa357/impl/src/main/java/org/apache/myfaces/webapp/FacesInitializerImpl.java#L594]
 looks incorrect to me.

The logic in the function is:
 # Try to retrieve {{beanManager}} as {{java:comp/BeanManager}} in 
{{InitialContext}}
 # If this succeeds (i.e. {{beanManager}} is non-null), try to retrieve 
{{beanManager}} as {{java:comp/env/BeanManager}} in {{InitialContext}}

The second step should be done if the first attempt to retrieve {{beanManager}} 
fails, not if it succeeds. (If my interpretation is wrong, I think an 
explanatory comment is warranted here!)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to