Using getElement() instead of get() to get proper synchronization.
This commit is contained in:
parent
542a17c3bc
commit
50b4e3f4b9
@ -15,16 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
import com.google.gson.ObjectNavigator.Visitor;
|
|
||||||
import com.google.gson.internal.$Types;
|
|
||||||
import com.google.gson.internal.$Preconditions;
|
|
||||||
|
|
||||||
import java.lang.reflect.AccessibleObject;
|
import java.lang.reflect.AccessibleObject;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.gson.ObjectNavigator.Visitor;
|
||||||
|
import com.google.gson.internal.$Preconditions;
|
||||||
|
import com.google.gson.internal.$Types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visits each of the fields of the specified class using reflection
|
* Visits each of the fields of the specified class using reflection
|
||||||
*
|
*
|
||||||
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
final class ReflectingFieldNavigator {
|
final class ReflectingFieldNavigator {
|
||||||
|
|
||||||
private static final LruCache<Type, List<FieldAttributes>> fieldsCache =
|
private static final Cache<Type, List<FieldAttributes>> fieldsCache =
|
||||||
new LruCache<Type, List<FieldAttributes>>(500);
|
new LruCache<Type, List<FieldAttributes>>(500);
|
||||||
|
|
||||||
private final ExclusionStrategy exclusionStrategy;
|
private final ExclusionStrategy exclusionStrategy;
|
||||||
@ -73,7 +73,7 @@ final class ReflectingFieldNavigator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<FieldAttributes> getAllFields(Type type, Type declaredType) {
|
private List<FieldAttributes> getAllFields(Type type, Type declaredType) {
|
||||||
List<FieldAttributes> fields = fieldsCache.get(type);
|
List<FieldAttributes> fields = fieldsCache.getElement(type);
|
||||||
if (fields == null) {
|
if (fields == null) {
|
||||||
fields = new ArrayList<FieldAttributes>();
|
fields = new ArrayList<FieldAttributes>();
|
||||||
for (Class<?> curr : getInheritanceHierarchy(type)) {
|
for (Class<?> curr : getInheritanceHierarchy(type)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user