Skip to content
This repository has been archived by the owner on Jun 16, 2019. It is now read-only.

Commit

Permalink
Caching fix
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed Feb 27, 2017
1 parent 5a6a6ee commit c36c53c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/afollestad/ason/AsonSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@SuppressWarnings({"unchecked", "WeakerAccess", "unused"}) class AsonSerializer {

private static AsonSerializer serializer;
private Map<Class<?>, ClassCacheEntry> classCache;
private Map<String, ClassCacheEntry> classCache;

AsonSerializer() {
classCache = new HashMap<>(0);
Expand Down Expand Up @@ -151,9 +151,10 @@ private Object serializeField(final Field field, final Object object) {
throw new IllegalArgumentException("You cannot deserialize an object to a JSON array.");
}

ClassCacheEntry<T> cacheEntry = classCache.get(cls);
ClassCacheEntry<T> cacheEntry = classCache.get(cls.getName());
if (cacheEntry == null) {
cacheEntry = new ClassCacheEntry<>(cls);
classCache.put(cls.getName(), cacheEntry);
}
final T newObject = cacheEntry.newInstance();

Expand Down

0 comments on commit c36c53c

Please sign in to comment.