@Override public void onResume() { getContext().onFailure(new Exception("Resume after a restart not supported for non-blocking synchronous steps")); }
@Override public String getStatus() { String supe = super.getStatus(); return delegate != null ? delegate.getClass().getName() + ": " + supe : supe; }
@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; }
@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 void stop(Throwable cause) throws Exception { LOGGER.log(Level.FINE, "Stopping container log step."); try { super.stop(cause); } finally { closeQuietly(getContext(), client); } } }
@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; }
@Override public void onResume() { getContext().onFailure(new Exception("Resume after a restart not supported for non-blocking synchronous steps")); }
/** * 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; } }); }
@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); } } });