Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-9593

Improve Exception management in Synchronous EventListeners

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.5
    • Fix Version/s: 5.6-RC1, 5.6
    • Component/s: Core

      Description

      Here is the current code that runs synchonous event listeners :

       if (desc.acceptEvent(ename)) {
                      try {
                          long t0 = System.currentTimeMillis();
                          desc.asEventListener().handleEvent(event);
                          if (stats != null) {
                              stats.logSyncExec(desc, System.currentTimeMillis() - t0);
                          }
                      } catch (Throwable t) {
                          log.error("Error during sync listener execution", t);
                      } finally {
                          if (event.isMarkedForRollBack()) {
                              throw new RuntimeException(
                                      "Exception during sync listener execution, rollingback");
                          }
                          if (event.isCanceled()) {
                              return;
                          }
                      }
                  }
      

      There are several points that could be improved :

      • we don't automatically rollback transaction in case an EventListener raises an Exception, this should be said in the Log
        (not rolling back transaction because {event.markRollBack()}

        was not called ...)

      • we do the rollback if event.markRollBack() was called, but in the returned RunTimeException we have no Exception / Message comming from the Listener itself

      => application level code can not access the root cause of the error (bad for debugging, but also for low level Application Checks that can be done via Listeners)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tdelprat Thierry Delprat
                Reporter:
                tdelprat Thierry Delprat
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: