Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-8191

Exception thrown in event listener for RepositoryDeletedRequestedEvent rolls back transaction

XMLWordPrintable

      When trying to handle a RepositoryDeletionRequestedEvent (possibly more, not verified) in Bitbucket Server, e.g.:

      @EventListener
      public void repositoryDeletionRequestedEventListener(RepositoryDeletionRequestedEvent evt) {
      	try {
      		someService.doStuff(); //throws exception in some cases
      	} catch (Exception e) {
      		// log exception and continue
      	}
      }
      

      The documentation of RepositoryDeletedRequestedEvent (along with other CancelableEvents) clearly states: "Throwing an exception will not prevent the repository from being deleted; the exception will be logged and ignored.".

      However, when an exception is thrown in the service, propagating to the eventlistener, I get "org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only" and the repository is never deleted.
      I've tried enabling all debug/trace-logging I could think of and the log suggests that the transaction is set to rollback-only just after the exception is thrown. However, the exception is logged by my code as well, suggesting that the catch-statement is actually also being run.

              Unassigned Unassigned
              35d468e06a7f Christoffer Kylvåg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: