struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4827) Not fully initialized ObjectFactory tries to create beans
Date Fri, 04 Aug 2017 12:47:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16114316#comment-16114316
] 

ASF GitHub Bot commented on WW-4827:
------------------------------------

Github user yasserzamani commented on the issue:

    https://github.com/apache/struts/pull/153
  
    @aleksandr-m , I modified `ObjectFactory` as below
    
    ```java
    ...
        private List<Object> myPrivateInjectQueue;
    ...
        @Inject
        public void setContainer(Container container) {
            this.container = container;
            if(null != this.container && null!=myPrivateInjectQueue && myPrivateInjectQueue.size()>0)
            {
                for(Object obj : myPrivateInjectQueue) this.container.inject(obj);
                myPrivateInjectQueue.clear();
                myPrivateInjectQueue=null;
            }
        }
    ...
        protected Object injectInternalBeans(Object obj) {
            if (obj != null) {
                if(container != null) container.inject(obj);
                else {
                    if(null==myPrivateInjectQueue)myPrivateInjectQueue=new ArrayList<Object>();
                    myPrivateInjectQueue.add(obj);}
            }
            return obj;
        }
    
    ```
    in your sample I got following ok result :)
    
    ```
    moving setContainer method to the last element of the array
    DateConverter.DateConverter()
    moving setContainer method to the last element of the array
    DateConverter.DateConverter()
    DateConverter.convertToString() localizedTextProvider=com.opensymphony.xwork2.util.StrutsLocalizedTextProvider@3f6f10fa
    
    ```


> Not fully initialized ObjectFactory tries to create beans
> ---------------------------------------------------------
>
>                 Key: WW-4827
>                 URL: https://issues.apache.org/jira/browse/WW-4827
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.5.12
>            Reporter: Aleksandr Mashchenko
>            Assignee: Lukasz Lenart
>            Priority: Critical
>             Fix For: 2.5.13
>
>
> This leads to issues when properties aren't injected in some cases, for example in custom
type converters.
> The problem happens when {{ObjectFactory}} tries to create a bean in the same time not
being fully initialized itself (e.g. {{ConverterFactory}} injected before {{Container}}).
> The issue happens more often under linux (all the time basically) than under windows,
so it cannot be reproduced 100%. This behavior boils down to the fact that {{clazz.getDeclaredMethods()}}
is used to get methods which needs to be injected and {{clazz.getDeclaredMethods()}} returned
elements are - _The elements in the array returned are not sorted and are not in any particular
order._
> Proposed solution moves Container injection from method to constructor in ObjectFactory
-  https://github.com/aleksandr-m/struts/commit/6f91d0776a545c911ca4f2875ed9976614711ef9.
> The downside is it isn't backward-compatible, custom object factories must be updated.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message