Exception thrown in event listener for RepositoryDeletedRequestedEvent rolls back transaction

XMLWordPrintable

    • 1
    • Severity 3 - Minor
    • 0

      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.

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

              Created:
              Updated:
              Resolved: