Uploaded image for project: 'JBoss Transaction Manager'
  1. JBoss Transaction Manager
  2. JBTM-3243

Use PostConstruct/PreDestroy for ApplicationScoped bean (instead of Observer)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 5.10.3.Final
    • 5.10.1.Final
    • LRA
    • None

      The LRA implementation needs to observe application shutdown in order to perform clean up activities. It achieves this using an ApplicationScoped bean. But when the destroyed event is fired a new bean may be created which is not what we want with an application scoped bean (this behaviour is seen when running as a Quarkus app). Annotating the method with `@PreDestroy` will ensure the correct application scoped bean used. So instead of

      void disableRecovery(@Observes @Destroyed(ApplicationScoped.class) Object ignore)
      

      use

          @PreDestroy
          void disableRecovery()
      

            rhn-engineering-mmusgrov Michael Musgrove
            rhn-engineering-mmusgrov Michael Musgrove
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: