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

Fix Automation REST operation context session stacks cleanup

    XMLWordPrintable

    Details

      Description

      Context

      When using Automation and the Auth.LoginAs operation is used, the org.nuxeo.ecm.automation.LoginStack is filled with extra sessions along the Automation execution.

      Unless the Auth.Logout operation is not called, the Login stack is cleanup at the end by org.nuxeo.ecm.automation.OperationContext#dispose.

      In a JAX-RS context, this cleanup is deferred and handled by org.nuxeo.ecm.automation.jaxrs.io.operations.RestOperationContext in a cleanup handler executed by Http filter org.nuxeo.ecm.webengine.jaxrs.context.RequestContextFilter.

      Issue

      When reproducing this use case, another filter is cleaned up started Tx: org.nuxeo.ecm.webengine.app.WebEngineFilter#cleanup and is executing before this REST Automation operation context.

      --> When entering in org.nuxeo.ecm.automation.OperationContext#dispose the extra started Tx is already commited which crashing the server response.

      Solution

      One solution would be:

      • To move this org.nuxeo.ecm.webengine.app.WebEngineFilter#cleanup into a dispose of cleanup handler
      • To control the scheduling of this cleanup after the Rest Operation Context deferred cleanup.

      Last extra issue

      We cannot test it properly in unit test for instance in org.nuxeo.ecm.automation.server.test.EmbeddedAutomationClientTest because in the test framework by default, there is no filter org.nuxeo.ecm.webengine.app.WebEngineFilter -> Not good for the tests in general!

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: