Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-1559

Cannot reliably use optional service dependencies

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • 8.0.0.Alpha2
    • None
    • MSC
    • None

      The OSGi transaction extension uses this code to define dependencies on some Tx services

                  builder.addDependency(DependencyType.OPTIONAL, TransactionManagerService.SERVICE_NAME, TransactionManager.class, injectedTransactionManager);
                  builder.addDependency(DependencyType.OPTIONAL, UserTransactionService.SERVICE_NAME, UserTransaction.class, injectedUserTransaction);
      

      and later registers OSGi services from it

              TransactionManager transactionManager = injectedTransactionManager.getOptionalValue();
              if (transactionManager != null) {
                  systemContext.registerService(TransactionManager.class.getName(), transactionManager, null);
              }
              UserTransaction userTransaction = injectedUserTransaction.getOptionalValue();
              if (userTransaction != null) {
                  systemContext.registerService(UserTransaction.class.getName(), userTransaction, null);
              }
      

      The intension is that the OSGi services only get registered when the Tx subsystem is configured.

      I see intermittent failures because the Tx services are not injected and suspect that this is due to a race condition in subsystem startup.

              dlloyd@redhat.com David Lloyd
              tdiesler@redhat.com Thomas Diesler
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: