Skip to content

Commit

Permalink
NXP-30657: forward principal to new thread
Browse files Browse the repository at this point in the history
  • Loading branch information
guirenard committed Nov 9, 2021
1 parent a8eb309 commit d61eb1d
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -32,6 +32,8 @@
import org.nuxeo.ecm.automation.core.util.Properties;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.NuxeoException;
import org.nuxeo.ecm.core.api.NuxeoPrincipal;
import org.nuxeo.ecm.core.api.local.ClientLoginModule;
import org.nuxeo.runtime.transaction.TransactionHelper;

/**
Expand Down Expand Up @@ -79,7 +81,9 @@ public void run() throws OperationException {
return;
}
try {
NuxeoPrincipal principal = session.getPrincipal();
TransactionHelper.runInNewTransaction(() -> {
ClientLoginModule.getThreadLocalLogin().push(principal, null, null);
try (OperationContext subctx = ctx.getSubContext(isolate)) {
try {
service.run(subctx, chainId, chainParameters);
Expand All @@ -90,6 +94,8 @@ public void run() throws OperationException {
// just log, no rethrow
log.error("Error while executing operation " + chainId, e);
}
} finally {
ClientLoginModule.getThreadLocalLogin().pop();
}
}
});
Expand Down

0 comments on commit d61eb1d

Please sign in to comment.