/** * 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 */privatevoid resetDeprecationLogger(finalboolean 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) {
thrownew AssertionError("IOException thrown while closing deprecation logger's thread context", ex);
}
if (setNewThreadContext) {
this.threadContext = newThreadContext(Settings.EMPTY);
DeprecationLogger.setThreadContext(this.threadContext);
} else {
this.threadContext = null;
}
}