@Override public final boolean start() throws Exception { final Authentication auth = Jenkins.getAuthentication(); task = SynchronousNonBlockingStepExecution.getExecutorService().submit(new Runnable() { @SuppressFBWarnings(value="SE_BAD_FIELD", justification="not serializing anything here") @Override public void run() { try { getContext().onSuccess(ACL.impersonate(auth, new NotReallyRoleSensitiveCallable<T, Exception>() { @Override public T call() throws Exception { threadName = Thread.currentThread().getName(); return AbstractSynchronousNonBlockingStepExecution.this.run(); } })); } catch (Exception e) { getContext().onFailure(e); } } }); return false; }
@Override public final boolean start() throws Exception { final Authentication auth = Jenkins.getAuthentication(); task = getExecutorService().submit(new Runnable() { @SuppressFBWarnings(value="SE_BAD_FIELD", justification="not serializing anything here") @Override public void run() { try { getContext().onSuccess(ACL.impersonate(auth, new NotReallyRoleSensitiveCallable<T, Exception>() { @Override public T call() throws Exception { threadName = Thread.currentThread().getName(); return SynchronousNonBlockingStepExecution.this.run(); } })); } catch (Exception e) { getContext().onFailure(e); } } }); return false; }
@Override public final boolean start() throws Exception { final Authentication auth = Jenkins.getAuthentication(); task = SynchronousNonBlockingStepExecution.getExecutorService().submit(new Runnable() { @SuppressFBWarnings(value="SE_BAD_FIELD", justification="not serializing anything here") @Override public void run() { try { getContext().onSuccess(ACL.impersonate(auth, new NotReallyRoleSensitiveCallable<T, Exception>() { @Override public T call() throws Exception { threadName = Thread.currentThread().getName(); return AbstractSynchronousNonBlockingStepExecution.this.run(); } })); } catch (Exception e) { getContext().onFailure(e); } } }); return false; }
/** * Initiate background work that should not block the CPS VM thread. * Call this from a CPS VM thread, such as from {@link #start} or {@link BodyExecutionCallback#onSuccess}. * The block may finish by calling {@link BodyInvoker#start}, {@link StepContext#onSuccess}, etc. * @param block some code to run in a utility thread */ protected final void run(Block block) { if (stopCause != null) { return; } final Authentication auth = Jenkins.getAuthentication(); task = SynchronousNonBlockingStepExecution.getExecutorService().submit(() -> { threadName = Thread.currentThread().getName(); try { try (ACLContext acl = ACL.as(auth)) { block.run(); } } catch (Throwable x) { if (stopCause == null) { getContext().onFailure(x); } else { stopCause.addSuppressed(x); } } finally { threadName = null; task = null; } }); }
@Override public final boolean start() throws Exception { final Authentication auth = Jenkins.getAuthentication(); task = getExecutorService().submit(() -> { threadName = Thread.currentThread().getName(); try { T ret; try (ACLContext acl = ACL.as(auth)) { ret = run(); } getContext().onSuccess(ret); } catch (Throwable x) { if (stopCause == null) { getContext().onFailure(x); } else { stopCause.addSuppressed(x); } } }); return false; }