0

I have a dispose listener which has a Job created inside widgetDisposed(DisposeEvent event) method. So executing this method when the TreeViewer gets disposed is causing, An internal error occurred during: "Cleanup Job". No context available outside of the request service lifecycle. This code is used by both RCP and RAP, works fine on RCP app.Issue is with RAP. Can any one suggest what's going wrong with this?

private void addDisposeListener() {
    treeViewer.getTree().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent event) {
            Job CleanupJob = new Job("Cleanup Job") { //$NON-NLS-1$

                @Override
                protected IStatus run(IProgressMonitor arg0) {
                    doCleanup();
                    return Status.OK_STATUS;
                }
            };

            CleanupJob.setUser(false);
            CleanupJob.setSystem(true);
            CleanupJob.schedule();

        }
    });
}
greg-449
  • 109,219
  • 232
  • 102
  • 145
Juseeth
  • 467
  • 1
  • 6
  • 18

1 Answers1

1

It seems that RAP tries to execute Jobs that are created in the UI thread in the context of the current UISession (see JobManagerAdapter in rap.ui.workbench). However, in your particular case, the Job is expected to be executed in application ("system") scope.

If the widget is disposed as a result of the session being terminated, this Job would like run after the session termination. This could explain the error.

I would suggest that you file a bug against RAP and include a stacktrace.

In the meantime, you may consider alternatives to using a Job for cleanup. For example, when cleanup is a global task, you could have a single "cleanup agent" that is notified by dispose listeners and schedules cleanup asynchronously.

ralfstx
  • 3,893
  • 2
  • 25
  • 41