Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1157

Bean creation is blocked across all threads until method annotated with @PostConstruct has finished

    XMLWordPrintable

Details

    • Hide

      To reproduce:
      1) Deploy attached WAR project
      2) Go to http://server:port/weld-test/block.xhtml, which will sleep in ac bean in @PostConstruct for 10 seconds
      3) Immediately open another browser tab and go to http://server:port/weld-test/dont-block.xhtml

      Observe that the last page (dont-block.xhtml) will not finish loading until the sleep in the other bean is done.

      Show
      To reproduce: 1) Deploy attached WAR project 2) Go to http://server:port/weld-test/block.xhtml , which will sleep in ac bean in @PostConstruct for 10 seconds 3) Immediately open another browser tab and go to http://server:port/weld-test/dont-block.xhtml Observe that the last page (dont-block.xhtml) will not finish loading until the sleep in the other bean is done.

    Description

      When creating two or more conversation scoped beans, the creation of the second bean will block until any method annotated with @PostConstruct is finished.

      In my example WAR project I have two JSF pages: one accesses a conversation scoped bean that sleeps for 10 seconds in a method annotated with @PostConstruct. The other accesses a conversation scoped bean that does not have any method annotated with @PostConstruct.

      While the first page is loading, the second page will be unable to finish, because bean creation is blocked completely.

      The lock seems to be acquired here:
      https://github.com/weld/core/blob/1.1.5.Final/impl/src/main/java/org/jboss/weld/context/AbstractContext.java#L101

      ... and postconstruct is called here:
      https://github.com/weld/core/blob/1.1.5.Final/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java#L291

      Attachments

        Activity

          People

            sdouglas1@redhat.com Stuart Douglas
            vetler_jira Vetle Leinonen-Roeim (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: