glassfish
  1. glassfish
  2. GLASSFISH-15146

InjectionManager.inject doesn't handle PostConstruct methods properly

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1
    • Component/s: naming
    • Labels:
      None

      Description

      The InjectionManagerImpl.inject method takes a boolean that controls whether postConstruct
      methods are called. Fortunately, most of the time it's called with "false". I think the
      only time it's called with "true" is when injecting an app client main class.

      If called with true, the PostConstruct invocation logic ignores method overriding and may call
      PostConstruct methods that shouldn't be called, or may call the same method more than once.

        Activity

        Bill Shannon created issue -
        Hide
        Hong Zhang added a comment -

        assign to tim to look at the client aspect.

        Show
        Hong Zhang added a comment - assign to tim to look at the client aspect.
        Hong Zhang made changes -
        Field Original Value New Value
        Assignee Hong Zhang [ hzhang_jn ] Tim Quinn [ tjquinn ]
        Affects Version/s 3.2 [ 10969 ]
        Affects Version/s V3 [ 10981 ]
        Hide
        Cheng Fang added a comment -

        As a data point, JSF has a requirement to perform the injection, but not do the @PostConstruct invocation immediatley following injection. Roger added this flag to enable this in 7/2010.

        Show
        Cheng Fang added a comment - As a data point, JSF has a requirement to perform the injection, but not do the @PostConstruct invocation immediatley following injection. Roger added this flag to enable this in 7/2010.
        Jill Sato made changes -
        Affects Version/s 4.0 [ 10970 ]
        Affects Version/s 3.2 [ 10969 ]
        Hide
        Tim Quinn added a comment -

        If the InjectionManagerImpl class is not working correctly then that doesn't seem to be an app client issue.

        The spec requires an app client main class @PostConstruct method to be invoked if it exists, so the ACC must invoke the injection manager impl in a way that causes @PostConstruct methods to be invoked.

        I am not sure whether this is really a deployment issue or a naming issue or something else, but for the moment I'm leaving the component as "deployment" and bouncing it back to Hong.

        Show
        Tim Quinn added a comment - If the InjectionManagerImpl class is not working correctly then that doesn't seem to be an app client issue. The spec requires an app client main class @PostConstruct method to be invoked if it exists, so the ACC must invoke the injection manager impl in a way that causes @PostConstruct methods to be invoked. I am not sure whether this is really a deployment issue or a naming issue or something else, but for the moment I'm leaving the component as "deployment" and bouncing it back to Hong.
        Tim Quinn made changes -
        Assignee Tim Quinn [ tjquinn ] Hong Zhang [ hzhang_jn ]
        Hide
        Hong Zhang added a comment -

        Assign to naming module to see if this part of the InjectionManager code is working as expected.

        Show
        Hong Zhang added a comment - Assign to naming module to see if this part of the InjectionManager code is working as expected.
        Hong Zhang made changes -
        Assignee Hong Zhang [ hzhang_jn ] guojun.shan [ guojun.shan ]
        Component/s naming [ 10636 ]
        Component/s deployment [ 10594 ]
        guojun.shan made changes -
        Fix Version/s 4.0.1 [ 16061 ]
        Hide
        guojun.shan added a comment -

        is this still a problem?
        I have a test case:
        Class A extends Class B.
        they both have methods annotated with @PostConstruct.
        the result is:
        if they have different method names, both the methods will be invoked.
        if they have method with the same name, only method in Class A will be invoked.

        Show
        guojun.shan added a comment - is this still a problem? I have a test case: Class A extends Class B. they both have methods annotated with @PostConstruct. the result is: if they have different method names, both the methods will be invoked. if they have method with the same name, only method in Class A will be invoked.
        Romain Grécourt made changes -
        Fix Version/s 4.1 [ 16387 ]
        Fix Version/s 4.0.1 [ 16061 ]

          People

          • Assignee:
            guojun.shan
            Reporter:
            Bill Shannon
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: