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

        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.
        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.
        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.
        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.
        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.

          People

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

            Dates

            • Created:
              Updated: