Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.entity.cache. (OFBIZ-9711) Thanks Dennis Balkir for reporting and providing the patch. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1813631 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vendored
+5
-13
@@ -65,12 +65,10 @@ public abstract class AbstractEntityConditionCache<K, V> extends AbstractCache<E
|
||||
public void remove(GenericEntity entity) {
|
||||
UtilCache.clearCache(getCacheName(entity.getEntityName()));
|
||||
ModelEntity model = entity.getModelEntity();
|
||||
if (model != null) {
|
||||
Iterator<String> it = model.getViewConvertorsIterator();
|
||||
while (it.hasNext()) {
|
||||
String targetEntityName = it.next();
|
||||
UtilCache.clearCache(getCacheName(targetEntityName));
|
||||
}
|
||||
Iterator<String> it = model.getViewConvertorsIterator();
|
||||
while (it.hasNext()) {
|
||||
String targetEntityName = it.next();
|
||||
UtilCache.clearCache(getCacheName(targetEntityName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +111,7 @@ public abstract class AbstractEntityConditionCache<K, V> extends AbstractCache<E
|
||||
EntityCondition conditionKey = getConditionKey(condition);
|
||||
ConcurrentMap<K, V> conditionCache = utilCache.get(conditionKey);
|
||||
if (conditionCache == null) {
|
||||
conditionCache = new ConcurrentHashMap<K, V>();
|
||||
conditionCache = new ConcurrentHashMap<>();
|
||||
utilCache.put(conditionKey, conditionCache);
|
||||
}
|
||||
return conditionCache;
|
||||
@@ -166,9 +164,6 @@ public abstract class AbstractEntityConditionCache<K, V> extends AbstractCache<E
|
||||
ModelEntity model = getModelCheckValid(oldEntity, newEntity);
|
||||
String entityName = model.getEntityName();
|
||||
// for info about cache clearing
|
||||
if (newEntity == null) {
|
||||
//Debug.logInfo("In storeHook calling sub-storeHook for entity name [" + entityName + "] for the oldEntity: " + oldEntity, module);
|
||||
}
|
||||
storeHook(entityName, isPK, UtilMisc.toList(oldEntity), UtilMisc.toList(newEntity));
|
||||
Iterator<String> it = model.getViewConvertorsIterator();
|
||||
while (it.hasNext()) {
|
||||
@@ -180,9 +175,6 @@ public abstract class AbstractEntityConditionCache<K, V> extends AbstractCache<E
|
||||
protected <T1 extends Map<String, Object>, T2 extends Map<String, Object>> void storeHook(String entityName, boolean isPK, List<T1> oldValues, List<T2> newValues) {
|
||||
UtilCache<EntityCondition, Map<K, V>> entityCache = UtilCache.findCache(getCacheName(entityName));
|
||||
// for info about cache clearing
|
||||
if (UtilValidate.isEmpty(newValues) || newValues.get(0) == null) {
|
||||
//Debug.logInfo("In storeHook (cache clear) for entity name [" + entityName + "], got entity cache with name: " + (entityCache == null ? "[No cache found to remove from]" : entityCache.getName()), module);
|
||||
}
|
||||
if (entityCache == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user