better handling of value from array when cleaning thread locals
This commit is contained in:
parent
f0007fd4ae
commit
7bac883837
|
@ -98,14 +98,15 @@ public class ThreadLocals {
|
|||
int staleEntriesCount = 0;
|
||||
if (table != null) {
|
||||
for (int j = 0; j < table.length; j++) {
|
||||
if (table[j] != null) {
|
||||
Object tableValue = table[j];
|
||||
if (tableValue != null) {
|
||||
boolean remove = false;
|
||||
// Check the key
|
||||
Object key = ((Reference<?>) table[j]).get();
|
||||
Object key = ((Reference<?>) tableValue).get();
|
||||
// Check the value
|
||||
Field valueField = table[j].getClass().getDeclaredField("value");
|
||||
Field valueField = tableValue.getClass().getDeclaredField("value");
|
||||
valueField.setAccessible(true);
|
||||
Object value = valueField.get(table[j]);
|
||||
Object value = valueField.get(tableValue);
|
||||
if ((value != null && CleanableValue.class.isAssignableFrom(value.getClass()))) {
|
||||
remove = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue