Skip to content

Commit abc303a

Browse files
authored
verify the cache entry is constructed (#99)
1 parent 7a7a0c1 commit abc303a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/java/com/aerospike/mapper/tools/ClassCache.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public <T> ClassCacheEntry<T> loadClass(@NotNull Class<T> clazz, IBaseAeroMapper
5656
}
5757

5858
ClassCacheEntry<T> entry = (ClassCacheEntry<T>) cacheMap.get(clazz);
59-
if (entry == null) {
59+
if (entry == null || entry.isNotConstructed()) {
6060
synchronized (lock) {
6161
entry = (ClassCacheEntry<T>) cacheMap.get(clazz);
6262
if (entry == null) {
@@ -85,6 +85,9 @@ public <T> ClassCacheEntry<T> loadClass(@NotNull Class<T> clazz, IBaseAeroMapper
8585
} catch (IllegalArgumentException iae) {
8686
cacheMap.remove(clazz);
8787
return null;
88+
} catch (Exception e) {
89+
cacheMap.remove(clazz);
90+
throw e;
8891
}
8992
}
9093
}

src/main/java/com/aerospike/mapper/tools/ClassCacheEntry.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ private enum FactoryMethodType {
101101
private String shortenedClassName;
102102
private boolean isChildClass = false;
103103

104+
private volatile boolean constructed;
104105

105106
// package visibility only.
106107
ClassCacheEntry(@NotNull Class<T> clazz, IBaseAeroMapper mapper, ClassConfig config,
@@ -160,9 +161,14 @@ public ClassCacheEntry<T> construct() {
160161
ClassCache.getInstance().setStoredName(this, this.shortenedClassName);
161162

162163
this.checkRecordSettingsAgainstSuperClasses();
164+
constructed = true;
163165
return this;
164166
}
165167

168+
public boolean isNotConstructed() {
169+
return !constructed;
170+
}
171+
166172
public Policy getReadPolicy() {
167173
return readPolicy;
168174
}

0 commit comments

Comments
 (0)