8308235: ThreadContainer registry accumulates weak refs

Reviewed-by: jpai
This commit is contained in:
Alan Bateman 2023-05-23 07:05:07 +00:00
parent 5d8ba938be
commit ada416e66c
2 changed files with 52 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -65,7 +65,7 @@ public class ThreadContainers {
*/
public static Object registerContainer(ThreadContainer container) {
expungeStaleEntries();
var ref = new WeakReference<>(container);
var ref = new WeakReference<>(container, QUEUE);
CONTAINER_REGISTRY.add(ref);
return ref;
}