Returns current stack information. It is called by log handler to get
thread specific information which is either passed for the record in a
request or obtained from the thread directly.

@return {@link StackInfo} instance setup in the current thread
439434
public static StackInfo getStack() {
		 StackInfo result = MDC.get();
		 return result == null ? new StackInfo() : result;
	 }
300513
public static StackTraceElement getMyStackTraceElement () {
		StackTraceElement myStackTraceElement = null;
		
		StackTraceElement[] stackTraceElements = Thread.currentThread ().getStackTrace ();
		if (stackTraceElements != null) {
			if (stackTraceElements.length > 2) {
				myStackTraceElement = stackTraceElements[2];
			}
		}

		return myStackTraceElement;
	}
515736
@Override
  public int getCurrentStackSize() {
    int stackSize = -1;
    if (this.tracingContextMap.containsKey(Thread.currentThread()))
      stackSize = this.tracingContextMap.get(Thread.currentThread()).getMethodStack().size();
    
    return stackSize;
  }
944398
public ThreadInfo[] getThreadDump() {
        ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean();
        return threadMxBean.dumpAllThreads(true, true);
    }
385316
public String getStacktrace() {

        String stacktrace = CmsException.getStackTraceAsString(getLoginException());
        stacktrace = CmsEncoder.escapeXml(stacktrace);
        return stacktrace;
    }
1070838
public static BegunTx<?> getBegunTxOnThread() {
        final Stack<BegunTx<?>> stack = threadLocal.get();
        return stack != null ? stack.peek() : null;
    }
1031353
public String getThreadName() {
        if (mThreadName == null) {
            Thread t = getThread();
            if (t != null) {
                mThreadName = t.getName();
            }
        }
        return mThreadName;
    }
39263
private static ProcessHandle getCurrentProcess() {
		try {
			return (ProcessHandle) ProcessHandle.class.getDeclaredMethod("current").invoke(null);
		} catch (ReflectiveOperationException ex) {
			InternalLogger.log(Level.ERROR, ex, "Failed to receive the handle of the current process");
			return null;
		}
	}
1209922
public Stack<FailureStackElement> getFailureStack() {
        Stack<FailureStackElement> stack = new Stack<FailureStackElement>();
        
        for (FailureStackElement failureStackElement : failureStack) {
            stack.push(failureStackElement);
        }
        
        return stack;
    }
460136
protected ThreadFactory getThreadFactory() {
        return new ThreadFactory() {
            private final ThreadFactory parent = Executors.defaultThreadFactory();
            private final AtomicInteger tid = new AtomicInteger(1);

            @Override
            public Thread newThread(final Runnable task) {
              final Thread t = parent.newThread(task);
              t.setName(THREAD_PREFIX + tid.getAndIncrement());
              return t;
            }
          };
    }
444887
private static StackTraceElement getStackTrace() {
    StackTraceElement[] stack = Thread.currentThread().getStackTrace();

    int i = 2; // we can skip the first two (first is getStackTrace(), second is this method)
    while (i < stack.length) {
      boolean isLoggingClass = false;
      for (String loggingClass : loggingClasses) {
        String className = stack[i].getClassName();
        if (className.startsWith(loggingClass)) {
          isLoggingClass = true;
          break;
        }
      }
      if (!isLoggingClass) {
        break;
      }

      i += 1;
    }

    // if we didn't find anything, keep last element (probably shouldn't happen, but could if people add too many logging classes)
    if (i >= stack.length) {
      i = stack.length - 1;
    }
    return stack[i];
  }
230518
@Trivial
    protected SubjectThreadContext getSubjectThreadContext() {
        ThreadLocal<SubjectThreadContext> currentThreadLocal = getThreadLocal();
        SubjectThreadContext subjectThreadContext = currentThreadLocal.get();
        if (subjectThreadContext == null) {
            subjectThreadContext = new SubjectThreadContext();
            currentThreadLocal.set(subjectThreadContext);
        }
        return subjectThreadContext;
    }
985313
public K getCurrentKey()
    {
        lock.lock();
        try
        {
            Thread currentThread = Thread.currentThread();
            for (Entry<K,Thread> entry : threadMap.entrySet())
            {
                if (currentThread.equals(entry.getValue()))
                {
                    return entry.getKey();
                }
            }
            return null;
        }
        finally
        {
            lock.unlock();
        }
    }
945687
private static Class<? extends StackTraceElement> findClassCaller()
    {
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();

        for( int i = 2; i < stackTrace.length; i++ )
        {
            StackTraceElement call = stackTrace[i];
            if (!Log.class.isAssignableFrom(call.getClass()))
                return call.getClass();
        }

        return null;
    }
424096
public static Socket getCurrentSocket() {
        ConnectionHandler handler = connectionMap.get(Thread.currentThread());
        return (handler == null ? null : handler.getSocket());
    }
598450
private static String getThreadInfo(Thread thread) {
    final StringBuilder sb = new StringBuilder();

    sb.append("Thread:     ");
    sb.append(thread.getId());
    sb.append(" (");
    sb.append(thread.getName());
    sb.append(")");
    sb.append(lineSeparator);
    final StackTraceElement[] stack = thread.getStackTrace();
    if (stack.length == 0) {
      sb.append("        No Java callstack associated with this thread");
      sb.append(lineSeparator);
    } else {
      for (StackTraceElement element : stack) {
        sb.append("        at ");
        sb.append(element.getClassName());
        sb.append(".");
        sb.append(element.getMethodName());
        sb.append("(");
        final int lineNumber = element.getLineNumber();
        if (lineNumber == -2) {
          sb.append("Native Method");
        } else if (lineNumber >=0) {
          sb.append(element.getFileName());
          sb.append(":");
          sb.append(element.getLineNumber());
        } else {
          sb.append(element.getFileName());
        }
        sb.append(")");
        sb.append(lineSeparator);
      }
    }
    sb.append(lineSeparator);

    return sb.toString();
  }
1074031
public String getStack() {
		if (stackTrace == null) {
			if (stack == null) {
				StringWriter sw = new StringWriter(512);
				PrintWriter pw = new PrintWriter(sw, true);
				super.printStackTrace(pw);
				stackTrace = sw.toString().trim();
			} else {
				stackTrace = stack.trim();
			}
		}
		return stackTrace;
	}