resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS)); DeprecationLogger.setThreadContext(threadPool.getThreadContext()); resourcesToClose.add(() -> DeprecationLogger.removeThreadContext(threadPool.getThreadContext()));
/** * 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); } }
resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS)); DeprecationLogger.setThreadContext(threadPool.getThreadContext()); resourcesToClose.add(() -> DeprecationLogger.removeThreadContext(threadPool.getThreadContext()));
resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS)); DeprecationLogger.setThreadContext(threadPool.getThreadContext()); resourcesToClose.add(() -> DeprecationLogger.removeThreadContext(threadPool.getThreadContext()));
resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS)); DeprecationLogger.setThreadContext(threadPool.getThreadContext()); resourcesToClose.add(() -> DeprecationLogger.removeThreadContext(threadPool.getThreadContext()));