Use ordinary HashMap instead of WeakHashMap. Weak keys are of no use here because closer threads strongly refer to the closeable resource.