operator/src/main/java/oracle/kubernetes/operator/work/Fiber.java
private boolean doRun() {
    // isRequireUnlock will contain Boolean.FALSE when lock has already been
    // released in suspend
    Holder<Boolean> isRequireUnlock = new Holder<>(Boolean.TRUE);
    lock.lock();
    try {
      ClassLoader old;
      synchronized (this) {
        // currentThread is protected by the monitor for this fiber so
        // that it is accessible to cancel() even when the lock is held
        currentThread = Thread.currentThread();
        if (LOGGER.isFinerEnabled()) {
          LOGGER.finer("Thread entering doRunInternal(): {0}", currentThread);
        }

        old = currentThread.getContextClassLoader();
        currentThread.setContextClassLoader(contextClassLoader);
      }

      try {
        return doRunInternal(isRequireUnlock);
      } catch (OnExitRunnableException o) {
        // catching this exception indicates onExitRunnable in suspend() threw.
        // we must still avoid double unlock
        Throwable t = o.target;
        if (t instanceof Error) {
          throw (Error) t;
        }
        if (t instanceof RuntimeException) {
          throw (RuntimeException) t;
        }
        throw new RuntimeException(t);
      } finally {
        // reacquire current thread here because fiber processing
        // may already be running on a different thread (Note: isAlreadyExited
        // tracks this state
        Thread thread = Thread.currentThread();
        thread.setContextClassLoader(old);
        if (LOGGER.isFinerEnabled()) {
          LOGGER.finer("Thread leaving doRunInternal(): {0}", thread);
        }
      }
    } finally {
      if (isRequireUnlock.value) {
        synchronized (this) {
          currentThread = null;
          triggerExitCallback();
        }
        lock.unlock();
      }
    }
  }
/** Executes the fiber as much as possible. */
Executes the fiber as much as possible.
Executes the fiber as much as possible .
private boolean doRun() {
    Holder<Boolean> isRequireUnlock = new Holder<>(Boolean.TRUE);
    lock.lock();
    try {
      ClassLoader old;
      synchronized (this) {
        currentThread = Thread.currentThread();
        if (LOGGER.isFinerEnabled()) {
          LOGGER.finer("Thread entering doRunInternal(): {0}", currentThread);
        }
        old = currentThread.getContextClassLoader();
        currentThread.setContextClassLoader(contextClassLoader);
      }
      try {
        return doRunInternal(isRequireUnlock);
      } catch (OnExitRunnableException o) {
        Throwable t = o.target;
        if (t instanceof Error) {
          throw (Error) t;
        }
        if (t instanceof RuntimeException) {
          throw (RuntimeException) t;
        }
        throw new RuntimeException(t);
      } finally {
        Thread thread = Thread.currentThread();
        thread.setContextClassLoader(old);
        if (LOGGER.isFinerEnabled()) {
          LOGGER.finer("Thread leaving doRunInternal(): {0}", thread);
        }
      }
    } finally {
      if (isRequireUnlock.value) {
        synchronized (this) {
          currentThread = null;
          triggerExitCallback();
        }
        lock.unlock();
      }
    }
  }
private boolean doRun ( ) { Holder < Boolean > isRequireUnlock = new Holder < > ( Boolean . TRUE ) ; lock . lock ( ) ; try { ClassLoader old ; synchronized ( this ) { currentThread = Thread . currentThread ( ) ; if ( LOGGER . isFinerEnabled ( ) ) { LOGGER . finer ( "Thread entering doRunInternal(): {0}" , currentThread ) ; } old = currentThread . getContextClassLoader ( ) ; currentThread . setContextClassLoader ( contextClassLoader ) ; } try { return doRunInternal ( isRequireUnlock ) ; } catch ( OnExitRunnableException o ) { Throwable t = o . target ; if ( t instanceof Error ) { throw ( Error ) t ; } if ( t instanceof RuntimeException ) { throw ( RuntimeException ) t ; } throw new RuntimeException ( t ) ; } finally { Thread thread = Thread . currentThread ( ) ; thread . setContextClassLoader ( old ) ; if ( LOGGER . isFinerEnabled ( ) ) { LOGGER . finer ( "Thread leaving doRunInternal(): {0}" , thread ) ; } } } finally { if ( isRequireUnlock . value ) { synchronized ( this ) { currentThread = null ; triggerExitCallback ( ) ; } lock . unlock ( ) ; } } }
Executes the fiber as much as possible.
Executes the fiber as much as possible .
// isRequireUnlock will contain Boolean.FALSE when lock has already been // released in suspend // currentThread is protected by the monitor for this fiber so // that it is accessible to cancel() even when the lock is held // catching this exception indicates onExitRunnable in suspend() threw. // we must still avoid double unlock // reacquire current thread here because fiber processing // may already be running on a different thread (Note: isAlreadyExited // tracks this state