Skip to content

Commit

Permalink
better handling of value from array when cleaning thread locals
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed May 7, 2012
1 parent f0007fd commit 7bac883
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -98,14 +98,15 @@ private static void clearThreadLocalMap(Object map, Field internalTableField) th
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;
}
Expand Down

0 comments on commit 7bac883

Please sign in to comment.