This commit is contained in:
Redkale
2016-09-12 21:08:10 +08:00
parent a43f9a0121
commit 95f4cd0634

View File

@@ -177,11 +177,14 @@ public final class ResourceFactory {
checkName(name); checkName(name);
ConcurrentHashMap<String, ResourceEntry> map = this.store.get(clazz); ConcurrentHashMap<String, ResourceEntry> map = this.store.get(clazz);
if (map == null) { if (map == null) {
ConcurrentHashMap<String, ResourceEntry> sub = new ConcurrentHashMap(); synchronized (clazz) {
sub.put(name, new ResourceEntry(rs)); map = this.store.get(clazz);
store.put(clazz, sub); if (map == null) {
return null; map = new ConcurrentHashMap();
} else { store.put(clazz, map);
}
}
}
ResourceEntry re = map.get(name); ResourceEntry re = map.get(name);
if (re == null) { if (re == null) {
map.put(name, new ResourceEntry(rs)); map.put(name, new ResourceEntry(rs));
@@ -190,7 +193,6 @@ public final class ResourceFactory {
} }
return re == null ? null : (A) re.value; return re == null ? null : (A) re.value;
} }
}
public <A> A find(Class<? extends A> clazz) { public <A> A find(Class<? extends A> clazz) {
return find("", clazz); return find("", clazz);