Ends the current span with a status derived from the given (optional) Throwable, and closes the
given scope.

@param scope an object representing the scope
@param throwable an optional Throwable
@since 0.9
483280
public static void endScope(Closeable scope, @Nullable Throwable throwable) {
    traceStrategy.endScope(scope, throwable);
  }
92019
public static final void localFailureScope(FailureScope localFailureScope)
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "localFailureScope", localFailureScope);

        _localFailureScope = localFailureScope;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "localFailureScope");
    }
648387
public void endElement(String uri, String localName, String qName)
	    throws SAXException {
	// reduce the depth
	depth--;

	if (isExcluded()) {
	    // determine if exclusion ends with us
	    if (excludedDepth == depth)
	        excludedDepth = -1;

	    // either way, we have been excluded, so pass nothing through
	    return;
	}

	// if we're excepted (for now), include ourselves...
	if (isAccepted())
	    getContentHandler().endElement(uri, localName, qName);

	    if (DEBUG) {
		System.err.println("***   Closing tag: " + localName);
		System.err.println("***   acceptedDepths.size(): " + acceptedDepths.size());
		System.err.println("***   last accepted depth: " + ((Integer)acceptedDepths.peek()).intValue());
		System.err.println("***   depth: " + depth);
	    }

	// now, back off if we correspond to a "successful" start tag
        if (acceptedDepths.size() > 0 &&
		(((Integer)acceptedDepths.peek()).intValue()) == depth)
	    acceptedDepths.pop();
    }
1168898
@Override
  public final void onBeforeScopeDestruction (@Nonnull final IScope aScopeToBeDestroyed) throws Exception
  {
    if (LOGGER.isDebugEnabled ())
      LOGGER.debug ("onBeforeScopeDestruction for '" + toString () + "' in scope " + aScopeToBeDestroyed.toString ());

    // Check init state
    if (isInInstantiation ())
    {
      if (LOGGER.isWarnEnabled ())
        LOGGER.warn ("Object currently in instantiation is destroyed soon: " + toString ());
    }
    else
      if (!isInstantiated ())
      {
        if (LOGGER.isWarnEnabled ())
          LOGGER.warn ("Object not instantiated is destroyed soon: " + toString ());
      }

    // Check destruction state
    if (isInPreDestruction ())
    {
      if (LOGGER.isErrorEnabled ())
        LOGGER.error ("Object already in pre destruction is destroyed soon again: " + toString ());
    }
    else
      if (isInDestruction ())
      {
        if (LOGGER.isErrorEnabled ())
          LOGGER.error ("Object already in destruction is destroyed soon again: " + toString ());
      }
      else
        if (isDestroyed ())
        {
          if (LOGGER.isErrorEnabled ())
            LOGGER.error ("Object already destroyed is destroyed soon again: " + toString ());
        }

    setInPreDestruction (true);

    onBeforeDestroy (aScopeToBeDestroyed);

    // do not reset PreDestruction - happens in onScopeDestruction
  }
442949
public void endElement(final String namespaceURI, final String localName, final String qName) throws SAXException {
        addCdata();
        Node oldCurrentNode = stack.pop();
        if (oldCurrentNode != null) {
            currentNode = oldCurrentNode;
        }
    }
488901
public void endElement(String namespaceUri,
                           String localName,
                           String qualifiedName)
            throws SAXException {
        currentElement = null;
        currentDepth--;
        String indentation = indent(-1);
        String closingElement = "</" + getName(localName, qualifiedName) + ">";
        write(currentlyInLeafElement ? closingElement : nl + indentation + closingElement);
        currentlyInLeafElement = false;
        this.currentElement = null;
        if (frozenArtifactResolver.artifactInheritsVersionFromParent() &&
            ARTIFACT_ID.equals(qualifiedName) &&
            currentDepth == 1) {
            logger.info("[Freezehandler]: Artifact version " + frozenArtifactResolver.artifactFrozenVersion());
            write(nl + indentation + "<" + VERSION + ">" + frozenArtifactResolver.artifactFrozenVersion() + "</" + VERSION + ">");
        }
        switch (qualifiedName) {
            case GROUP_ID:
            case ARTIFACT_ID:
            case PACKAGING:
            case RELATIVE_PATH:
            case "":
                break;
            case VERSION:
            default:
                this.currentGroupIdArtifactIdVersion = new GroupIdArtifactIdVersion();
        }
    }
118602
void abort(Throwable t) throws IOException {
    LOG.info("Aborting because of " + StringUtils.stringifyException(t));
    try {
      downlink.abort();
      downlink.flush();
    } catch (IOException e) {
      // IGNORE cleanup problems
    }
    try {
      handler.waitForFinish();
    } catch (Throwable ignored) {
      process.destroy();
    }
    IOException wrapper = new IOException("pipe child exception");
    wrapper.initCause(t);
    throw wrapper;      
  }
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;
	}
954447
void processScope(Scope scope) {
    boolean shouldAddToBlockStack = !scope.isHoistScope();
    this.narrowScope = scope;
    if (shouldAddToBlockStack) {
      blockStack.add(new BasicBlock(null, scope.getRootNode()));
    }
    (new NodeTraversal(compiler, this, scopeCreator)).traverseAtScope(scope);
    if (shouldAddToBlockStack) {
      pop(blockStack);
    }
    this.narrowScope = null;
  }
155075
public static void closeScope(Object name) {
    //we remove the scope first, so that other threads don't see it, and see the next snapshot of the tree
    ScopeNode scope = (ScopeNode) MAP_KEY_TO_SCOPE.remove(name);
    if (scope != null) {
      ScopeNode parentScope = scope.getParentScope();
      if (parentScope != null) {
        parentScope.removeChild(scope);
      } else {
        ConfigurationHolder.configuration.onScopeForestReset();
      }
      removeScopeAndChildrenFromMap(scope);
    }
  }
891590
void endOffering(IOException exception) {
    if (closed) {
      return;
    }

    // closed should never be set by this method--only the polling side should do it, as it means
    // that the CLOSED marker has been encountered.

    if (this.exception == null) {
      this.exception = exception;
    }

    // Since this is an unbounded queue, offer() always succeeds.
    queue.offer(CLOSED);
  }
815344
public static void endContext(ControlContainerContext context)
    {
        Stack<ControlContainerContext> contextStack = _threadContexts.get();
        if (contextStack == null || contextStack.size() == 0)
            throw new IllegalStateException("No context started for current thread");

        if (contextStack.peek() != context)
            throw new IllegalStateException("Context is not the current active context");

        contextStack.pop();
    }
510457
@Override
  public synchronized void close() {
    if (endHandler != null) {
      endHandler.handle(null);
    }
    closed = true;
    if (listener != null && handleCalled) {
      listener.sessionClosed();
    }
  }
660729
public void finished() throws Throwable {
        if( state == FINISHED ) {
            return;
        }

        State previousState = state;

        state = FINISHED;
        methodInterceptor.enableMethodInterception( false );

        try {
            if( previousState == STARTED ) {
                callFinishLifeCycleMethods();
            }
        } finally {
            listener.scenarioFinished();
        }
    }
563753
private Status executeBreak(Stmt.Break stmt, CallStack frame, EnclosingScope scope) {
		// TODO: the break bytecode supports a non-nearest exit and eventually
		// this should be supported.
		return Status.BREAK;
	}
1108813
public void destroy() throws Exception {
        log.debug("Destroy scope");
        if (hasParent()) {
            parent.removeChildScope(this);
        }
        if (hasHandler()) {
            // Because handler can be null when there is a parent handler
            getHandler().stop(this);
        }
        // kill all child scopes
        for (IBasicScope child : children.keySet()) {
            removeChildScope(child);
            if (child instanceof Scope) {
                ((Scope) child).uninit();
            }
        }
    }
7578
public CompletableFuture<CreateScopeStatus> createScope(final String scope) {
        Exceptions.checkNotNullOrEmpty(scope, "scope");
        try {
            NameUtils.validateScopeName(scope);
        } catch (IllegalArgumentException | NullPointerException e) {
            log.warn("Create scope failed due to invalid scope name {}", scope);
            return CompletableFuture.completedFuture(CreateScopeStatus.newBuilder().setStatus(
                    CreateScopeStatus.Status.INVALID_SCOPE_NAME).build());
        }
        return streamStore.createScope(scope);
    }