private ThreadContext newThreadContext(String sslPrincipal) { ThreadContext threadContext = new ThreadContext(Settings.EMPTY); threadContext.putTransient(ConfigConstants.SG_SSL_PRINCIPAL, sslPrincipal); return threadContext; }
try (ThreadContext context = new ThreadContext(Settings.EMPTY)) { context.readHeaders(streamInput);
threadContext = new ThreadContext(settings);
/** * Reset the deprecation logger by removing the current thread context, and setting a new thread context if {@code setNewThreadContext} * is set to {@code true} and otherwise clearing the current thread context. * * @param setNewThreadContext whether or not to attach a new thread context to the deprecation logger */ private void resetDeprecationLogger(final boolean setNewThreadContext) { // "clear" current warning headers by setting a new ThreadContext DeprecationLogger.removeThreadContext(this.threadContext); try { this.threadContext.close(); // catch IOException to avoid that call sites have to deal with it. It is only declared because this class implements Closeable // but it is impossible that this implementation will ever throw an IOException. } catch (IOException ex) { throw new AssertionError("IOException thrown while closing deprecation logger's thread context", ex); } if (setNewThreadContext) { this.threadContext = new ThreadContext(Settings.EMPTY); DeprecationLogger.setThreadContext(this.threadContext); } else { this.threadContext = null; } }
@Before public final void before() { logger.info("[{}]: before test", getTestName()); assertNull("Thread context initialized twice", threadContext); if (enableWarningsCheck()) { this.threadContext = new ThreadContext(Settings.EMPTY); DeprecationLogger.setThreadContext(threadContext); } }
try (ThreadContext context = new ThreadContext(Settings.EMPTY)) { context.readHeaders(in);
try (ThreadContext threadContext = new ThreadContext(settings)) { Header[] defaultHeaders = new Header[threadContext.getHeaders().size()]; int i = 0;
executor = EsExecutors.newScaling("internal_test_cluster_executor", 0, Integer.MAX_VALUE, 0, TimeUnit.SECONDS, EsExecutors.daemonThreadFactory("test_" + clusterName), new ThreadContext(Settings.EMPTY));
threadContext = new ThreadContext(settings);
threadContext = new ThreadContext(settings);
threadContext = new ThreadContext(settings);