[Possible BUG] CrowdDirectoryService synchroniseDirectory throws Exception if invoked in blocking mode

Hi,

I’m developing a plugin for Bitbucket Data Center. I want to start a LDAP synchronization from my code.
I’m using the Crowd API com.atlassian.crowd.embedded.api.CrowdDirectoryService.synchroniseDirectory for that.
The synchroniseDirectory method has an overload which accepts a boolean for running synchronization in background.
If I invoke this method with ‘false’ it throws an exception. The relevant stack trace:

Existing transaction found for transaction marked with propagation 'never'
org.springframework.transaction.IllegalTransactionStateException: Existing transaction found for transaction marked with propagation 'never'
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:413)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:352)
        at com.atlassian.crowd.manager.directory.DirectoryManagerGeneric.synchroniseCache(DirectoryManagerGeneric.java:271)
        at jdk.internal.reflect.GeneratedMethodAccessor1881.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at com.atlassian.crowd.embedded.core.CrowdDirectoryServiceImpl.synchroniseDirectory(CrowdDirectoryServiceImpl.java:186)
        at com.atlassian.stash.internal.crowd.CustomizedCrowdDirectoryService.synchroniseDirectory(CustomizedCrowdDirectoryService.java:108)

Invoking this method with ‘true’ for doing a non-blocking synchronization works fine.
I think this is an internal issue in bitbucket as I don’t use any transactions.

Affected version: Bitbucket Data Center 8.2.1

Zoltan