rmuir commented on code in PR #816: URL: https://github.com/apache/lucene/pull/816#discussion_r855131404
########## lucene/core/src/java/org/apache/lucene/util/CloseableThreadLocal.java: ########## @@ -123,12 +122,34 @@ public void close() { // Clear the hard refs; then, the only remaining refs to // all values we were storing are weak (unless somewhere // else is still using them) and so GC may reclaim them: - hardRefs = null; - // Take care of the current thread right now; others will be - // taken care of via the WeakReferences. - if (t != null) { - t.remove(); + synchronized (lock) { + if (perThreadValues == null) { + return; + } + + perThreadValues.clear(); + perThreadValues = null; + } + } + + + /** + * Visible to test. + * + * @return per-thread values map. + */ + Map<String,T> getValuesAfterPurge() { + Map<String, T> values = new HashMap<>(); Review Comment: the CI build failed, i think we need to `import java.util.HashMap`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org