Terminates the JVM. It will cause System.exit() with exit code set in
{@link #setExitCode(int)} to be invoked on a separate thread.
@param e the virtual machine error that is the cause for terminating the
JVM
@throws IllegalArgumentException if e == null
961121
public static void terminateVM(VirtualMachineError e) {
        if(e == null) {
            throw new IllegalArgumentException("e == null");
        }
        if(terminating) {
            return;
        }
        // Ordering is important - these fields are volatile; we must first
        // set terminationCause and only after that terminating so that
        // checkTerminating() never observes (terminating==true &&
        // terminationCause == null)
        terminationCause = e;
        synchronized(lock) {
            terminating = true;
            lock.notify();
        }
    }
705499
public static boolean isTruncatedMessageException(IOException e) {
    if (!(e instanceof InvalidProtocolBufferException)) {
      return false;
    }
    String truncatedMessage;
    try {
      Method method = InvalidProtocolBufferException.class.getMethod("truncatedMessage");
      method.setAccessible(true);
      truncatedMessage = (String) method.invoke(null);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ee) {
      throw new RuntimeException(ee);
    }
    return e.getMessage().equals(truncatedMessage);
  }
1073049
public static void setConfigException(Throwable e)
  {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();

    for (; loader != null; loader = loader.getParent()) {
      if (loader instanceof EnvironmentClassLoader) {
        EnvironmentClassLoader envLoader = (EnvironmentClassLoader) loader;

        envLoader.setConfigException(e);

        return;
      }
    }
  }
1081389
@Override
	public void close(@NotNull Throwable e) {
		if (exception != null) return;
		exception = e instanceof Exception ? (Exception) e : new RuntimeException(e);
		if (put != null) {
			put.setException(e);
			put = null;
		}
		if (take != null) {
			take.setException(e);
			take = null;
		}
		tryRecycle(value);
		value = null;
	}
877738
public static void error(Throwable e) throws JMapperException{
		logger.error("{}: {}",e.getClass().getSimpleName(),e.getMessage());
		throw new JMapperException(e);
	}
325681
@Override
	public final void close(@NotNull Throwable e) {
		if (isProcessComplete()) return;
		processComplete = true;
		doClose(e);
		processCompletion.trySetException(e);
		afterProcess(e);
	}
68763
public static void e(Throwable e) {
		messager.printMessage(Diagnostic.Kind.ERROR, "exception thrown! " + e.getMessage());
	}
47847
@Override
	public void terminateMachine( TargetHandlerParameters parameters, String machineId ) throws TargetException {

		this.logger.fine( "Terminating machine " + machineId );
		ComputeService computeService = jcloudContext( parameters.getTargetProperties());
		computeService.destroyNode( machineId );
		computeService.getContext().close();
	}
1027350
protected void cleanUpAndThrow(RuntimeException e) {
        if (content != null && content.refCnt() > 0) {
            content.release();
        }
        throw e;
    }
395853
public void exception(Throwable e) {
    final String msg = e.getMessage();
    log(Level.SEVERE, msg != null ? msg : "An exception occurred.", e);
  }
850555
public void stopMessagingEngine(String busName, String name)
                    throws Exception {

        String thisMethodName = CLASS_NAME
                                + ".stopMessagingEngine(String, String)";

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, thisMethodName, new Object[] { busName, name });
        }

        stopMessagingEngine(busName, name, JsConstants.ME_STOP_IMMEDIATE);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, thisMethodName);
        }
    }
1190174
private void onUncleanExit(final String processId, final int exitCode) {
    this.onResourceStatus(
        ResourceStatusEventImpl.newBuilder()
            .setIdentifier(processId)
            .setState(State.FAILED)
            .setExitCode(exitCode)
            .build()
    );
  }
582434
protected void finishSendError(Exception e) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "finishSendError(exception): " + getVC());
        }
        WsByteBuffer[] body = (WsByteBuffer[]) getVC().getStateMap().remove(EPS_KEY);
        if (null != body) {
            for (int i = 0; i < body.length && null != body[i]; i++) {
                body[i].release();
            }
        }
        this.myLink.close(getVC(), e);
    }
1336256
protected void removeExecutor(final Executor e) {
        final Runnable task = new Runnable() {
            @Override
            public void run() {
                synchronized (Computer.this) {
                    executors.remove(e);
                    addNewExecutorIfNecessary();
                    if (!isAlive()) {
                        AbstractCIBase ciBase = Jenkins.getInstanceOrNull();
                        if (ciBase != null) { // TODO confirm safe to assume non-null and use getInstance()
                            ciBase.removeComputer(Computer.this);
                        }
                    }
                }
            }
        };
        if (!Queue.tryWithLock(task)) {
            // JENKINS-28840 if we couldn't get the lock push the operation to a separate thread to avoid deadlocks
            threadPoolForRemoting.submit(Queue.wrapWithLock(task));
        }
    }
1076207
private void shutdownImpl(ShutdownModeAmp mode, 
                            ExitCode exitCode,
                            Result<String> result)
  {
    // start the fail-safe thread in case the shutdown fails
    FailSafeHaltThread haltThread = _failSafeHaltThread;
    
    if (haltThread != null) {
      haltThread.startShutdown();
    }

    if (exitCode == null) {
      exitCode = ExitCode.FAIL_SAFE_HALT;
    }
    
    _exitCode.compareAndSet(null, exitCode);

    try {
      SystemManager systemManager = _systemManagerRef.get();
        
      if (systemManager != null) {
        systemManager.shutdown(mode);
      }
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
    } finally {
      _systemManagerRef = null;
      _lifecycle.toDestroy();

      System.err.println("\nShutdown reason: " + exitCode + "\n");

      log.warning("Shutdown reason: " + exitCode);
      
      if (result != null) {
        result.ok("Shutdown reason: " + exitCode);
      }

      if (! _isEmbedded) {
        System.exit(exitCode.ordinal());
      }
    }
  }
303815
@Override
    public void close(VirtualConnection inVC, Exception e) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "close, vc=" + getVCHash());
        }

        // Set closed flag so that ready can't be called again in an error condition.
        // This is a protective measure.
        closed = true;

        // Clean up the read and write interfaces as well as the SSL engine.

        // cleanup has logic to avoid writing if stop(0) has been called
        cleanup();

        //If the channel has already processed the close signal, it is too late to try and clean up the individual connection links here.
        //This race condition should not happen if channels above us are well behaved, so not using synchronize logic here, so as not to
        //impact mainline performance.
        if (this.sslChannel.getstop0Called() != true) {
            if (getDeviceLink() != null) {
                getDeviceLink().close(inVC, e);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "close");
        }
    }
1159504
@Override
    public void destroy(Exception e) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "destroy, vc=" + getVCHash());
        }

        // Clean up the read and write interfaces as well as the SSL engine.
        this.connected = false;
        cleanup();
        getVirtualConnection().getStateMap().remove(LINKCONFIG);
        if (this.syncConnectFailure) {
            // sync connect failure needs cleanup below us but not above
            // us on the connlink chain
            super.destroy();
        } else {
            // otherwise use the destroy that goes up the chain
            super.destroy(e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "destroy");
        }
    }